mori 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +51 -1
  4. data/Rakefile +1 -0
  5. data/app/controllers/mori/base_controller.rb +3 -0
  6. data/app/controllers/mori/invites_controller.rb +37 -0
  7. data/app/controllers/mori/passwords_controller.rb +59 -0
  8. data/app/controllers/mori/registrations_controller.rb +32 -7
  9. data/app/controllers/mori/sessions_controller.rb +10 -6
  10. data/app/helpers/mori_helper.rb +1 -1
  11. data/app/mailers/mori_mailer.rb +18 -0
  12. data/app/views/invites/new.html.erb +1 -0
  13. data/app/views/invites/show.html.erb +1 -0
  14. data/app/views/layouts/mori/application.html.erb +7 -1
  15. data/app/views/layouts/mori/form.html.erb +15 -0
  16. data/app/views/mori_forms/_accept_invite.html.erb +16 -0
  17. data/app/views/mori_forms/_change_password.html.erb +22 -0
  18. data/app/views/mori_forms/_forgot_password.html.erb +14 -0
  19. data/app/views/mori_forms/_invite_new_user_form.html.erb +14 -0
  20. data/app/views/mori_forms/_password_reset.html.erb +20 -0
  21. data/app/views/mori_forms/_registration.html.erb +22 -0
  22. data/app/views/mori_forms/_sessions.html.erb +18 -0
  23. data/app/views/mori_mailer/confirm_email.html.erb +4 -0
  24. data/app/views/mori_mailer/forgot_password.html.erb +7 -0
  25. data/app/views/mori_mailer/invite_user.html.erb +5 -0
  26. data/app/views/passwords/change.html.erb +1 -0
  27. data/app/views/passwords/forgot.html.erb +2 -0
  28. data/app/views/passwords/reset.html.erb +1 -0
  29. data/app/views/passwords/send_reset.html.erb +1 -0
  30. data/app/views/registrations/new.html.erb +2 -0
  31. data/app/views/sessions/new.html.erb +2 -0
  32. data/app/views/shared/_links.html.erb +11 -0
  33. data/config/database.travis.yml +3 -25
  34. data/config/initializers/warden.rb +5 -5
  35. data/config/locales/mori.en.yml +20 -16
  36. data/config/routes.rb +22 -2
  37. data/db/migrate/20140128055658_create_users.rb +29 -0
  38. data/lib/assets/javascripts/bootstrap.min.js +6 -0
  39. data/lib/assets/stylesheets/bootstrap.min.css +7 -0
  40. data/lib/generators/mori/install/install_generator.rb +130 -0
  41. data/lib/generators/mori/install/templates/db/migrate/add_mori_to_users.rb +23 -0
  42. data/{db/migrate/20140128055658_create_mori_users.rb → lib/generators/mori/install/templates/db/migrate/create_users.rb} +6 -9
  43. data/lib/generators/mori/install/templates/mori.rb +32 -0
  44. data/lib/generators/mori/install/templates/user.rb +3 -0
  45. data/lib/generators/mori/views/USAGE +12 -0
  46. data/lib/generators/mori/views/views_generator.rb +39 -0
  47. data/lib/mori/configuration.rb +17 -10
  48. data/lib/mori/controller.rb +25 -0
  49. data/lib/mori/engine.rb +2 -6
  50. data/lib/mori/password.rb +21 -0
  51. data/lib/mori/token.rb +3 -12
  52. data/lib/mori/user.rb +124 -0
  53. data/lib/mori/version.rb +1 -1
  54. data/lib/mori.rb +3 -3
  55. data/spec/dummy/app/assets/javascripts/application.js +2 -0
  56. data/spec/dummy/app/controllers/application_controller.rb +1 -0
  57. data/spec/dummy/app/models/user.rb +4 -0
  58. data/spec/dummy/app/views/application/index.html.erb +13 -0
  59. data/spec/dummy/app/views/application/test_login.html.erb +1 -0
  60. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  61. data/spec/dummy/config/application.rb +9 -7
  62. data/spec/dummy/config/database.yml +6 -24
  63. data/spec/dummy/config/environments/production.rb +2 -2
  64. data/spec/dummy/config/environments/test.rb +3 -3
  65. data/spec/dummy/config/initializers/mime_types.rb +2 -2
  66. data/spec/dummy/config/initializers/mori.rb +12 -1
  67. data/spec/dummy/config/initializers/secret_token.rb +6 -1
  68. data/spec/dummy/config/locales/en.yml +1 -1
  69. data/spec/dummy/config/routes.rb +2 -1
  70. data/spec/dummy/db/development.sqlite3 +0 -0
  71. data/spec/dummy/db/migrate/{20140209071716_create_users.mori_engine.rb → 20140421045106_create_users.mori_engine.rb} +2 -6
  72. data/spec/dummy/db/schema.rb +14 -21
  73. data/spec/dummy/db/test.sqlite3 +0 -0
  74. data/spec/dummy/log/development.log +14442 -21478
  75. data/spec/dummy/log/test.log +128933 -76950
  76. data/spec/dummy/public/404.html +1 -1
  77. data/spec/dummy/public/422.html +1 -1
  78. data/spec/dummy/public/500.html +1 -1
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/07db4022ed50ebf1535599a3e2344037 +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/09f817f5fe8888d5c59a3b285c3ef605 +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/19f899de0e04ccfd931a7a11e36aca13 +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/1b98ef3337306536c2890a74951d225c +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/2000a2ad47f8e201455b785beb7b1384 +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/22de1150643c428d3f508171d74347a3 +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/3453364cd811fec54cae0a92adc719e4 +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/4462cfec451130aa58d88b3da13913c3 +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/45753608d28d02693f8f6277074589a1 +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/56b349da612a4be9d5e6733778ce17e4 +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/5b3ef4ce70e1da7b1afd392754613726 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/770ff8b64985dd08cab8c32a1fa76438 +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/8e4cef792c949716da8fe3e9ee0cda70 +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/a6374c002de146da5c25b8cfd375ce6c +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/b085c718dd9381a5d4036f00b47d1b91 +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/c207a30f2b33f7df2c5336aed05485a2 +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/cf4d7483cd5aff334d69dd3173f9b953 +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/e2b0bfc208732a6cf47d67c1be32e54f +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  103. data/spec/dummy/tmp/cache/assets/test/sprockets/07db4022ed50ebf1535599a3e2344037 +0 -0
  104. data/spec/dummy/tmp/cache/assets/test/sprockets/09f817f5fe8888d5c59a3b285c3ef605 +0 -0
  105. data/spec/dummy/tmp/cache/assets/test/sprockets/1143c7a241c19613744d1a2be3ad7cd1 +0 -0
  106. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  107. data/spec/dummy/tmp/cache/assets/test/sprockets/19f899de0e04ccfd931a7a11e36aca13 +0 -0
  108. data/spec/dummy/tmp/cache/assets/test/sprockets/1b98ef3337306536c2890a74951d225c +0 -0
  109. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  110. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  111. data/spec/dummy/tmp/cache/assets/test/sprockets/39cd89cab4906d24583c876a477cf098 +0 -0
  112. data/spec/dummy/tmp/cache/assets/test/sprockets/4462cfec451130aa58d88b3da13913c3 +0 -0
  113. data/spec/dummy/tmp/cache/assets/test/sprockets/45753608d28d02693f8f6277074589a1 +0 -0
  114. data/spec/dummy/tmp/cache/assets/test/sprockets/56b349da612a4be9d5e6733778ce17e4 +0 -0
  115. data/spec/dummy/tmp/cache/assets/test/sprockets/5b3ef4ce70e1da7b1afd392754613726 +0 -0
  116. data/spec/dummy/tmp/cache/assets/test/sprockets/770ff8b64985dd08cab8c32a1fa76438 +0 -0
  117. data/spec/dummy/tmp/cache/assets/test/sprockets/8e4cef792c949716da8fe3e9ee0cda70 +0 -0
  118. data/spec/dummy/tmp/cache/assets/test/sprockets/9d5b4060cdb29606bd153ef2ca742a22 +0 -0
  119. data/spec/dummy/tmp/cache/assets/test/sprockets/a6374c002de146da5c25b8cfd375ce6c +0 -0
  120. data/spec/dummy/tmp/cache/assets/test/sprockets/b085c718dd9381a5d4036f00b47d1b91 +0 -0
  121. data/spec/dummy/tmp/cache/assets/test/sprockets/c1fb58de0c271425746c77af9e101750 +0 -0
  122. data/spec/dummy/tmp/cache/assets/test/sprockets/c207a30f2b33f7df2c5336aed05485a2 +0 -0
  123. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  124. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  125. data/spec/dummy/tmp/cache/assets/test/sprockets/e2b0bfc208732a6cf47d67c1be32e54f +0 -0
  126. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  127. data/spec/factories/mori_users.rb +8 -8
  128. data/spec/features/invites_spec.rb +64 -0
  129. data/spec/features/passwords_spec.rb +101 -0
  130. data/spec/features/registrations_spec.rb +37 -10
  131. data/spec/features/sessions_spec.rb +24 -28
  132. data/spec/helpers/mori_helper_spec.rb +3 -12
  133. data/spec/helpers.rb +10 -0
  134. data/spec/mailers/mori/mailer_spec.rb +24 -4
  135. data/spec/models/mori/user_spec.rb +187 -167
  136. data/spec/spec_helper.rb +17 -6
  137. metadata +108 -53
  138. data/app/assets/javascripts/mori/application.js +0 -13
  139. data/app/assets/stylesheets/mori/application.css +0 -13
  140. data/app/controllers/mori_controller.rb +0 -8
  141. data/app/mailers/mori/mailer.rb +0 -17
  142. data/app/models/mori/user.rb +0 -85
  143. data/app/views/mori/mailer/confirm_email.html.erb +0 -1
  144. data/app/views/mori/mailer/invite_user.html.erb +0 -1
  145. data/app/views/mori/mailer/password_reset_notification.html.erb +0 -1
  146. data/app/views/mori/registrations/new.slim +0 -9
  147. data/app/views/mori/sessions/new.slim +0 -8
  148. data/db/migrate/20140126052000_enable_hstore.rb +0 -9
  149. data/lib/mori/string.rb +0 -20
  150. data/spec/dummy/app/views/application/index.slim +0 -2
  151. data/spec/dummy/db/migrate/20140128055553_enable_hstore.mori.rb +0 -10
  152. data/spec/dummy/log/user.log +0 -43
  153. data/spec/dummy/tmp/pids/server.pid +0 -1
  154. data/spec/mailer_matcher.rb +0 -33
  155. data/spec/views/mori/registrations/create.html.erb_spec.rb +0 -5
  156. data/spec/views/mori/registrations/new.html.erb_spec.rb +0 -5
  157. data/spec/views/mori/sessions/create.html.erb_spec.rb +0 -5
  158. data/spec/views/mori/sessions/destroy.html.erb_spec.rb +0 -5
  159. data/spec/views/mori/sessions/new.html.erb_spec.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ee64fc60f4aa320446d6cddccf5be8fa3bbf432
4
- data.tar.gz: 0702dbfb25aec136a1f6bb806efb41001a487922
3
+ metadata.gz: e216ffc7bd86384021962479ecd4fc801a2c820e
4
+ data.tar.gz: 2a15f5d7f9d804ce568dbcc5d80a52ed31ba6648
5
5
  SHA512:
6
- metadata.gz: 941665ac96f3de8512dfc6c0d4cf73eae75dccd3d725ca1ef6176331df94d7f9e5720ed96d13ad13246643a989f17e7f33a964494d931809a3187b4521d1e8d7
7
- data.tar.gz: 0ce4f4f2fc046f623ba0368ba74a9faa6b10eee0254f07d40bc857df081a7a53b86cd3241c7922ffee5989f959f0b8e5724a7eecf905a74141ffedf23b573bf8
6
+ metadata.gz: 05baff8ea62aac281ca8e652328ef7cec128d6bfb7544bc61b277f265020d850a1f1a6b524cf4e52cf3a548f33dd6d5f07faf09e40eddc5f5308649f4e26c123
7
+ data.tar.gz: ea8d7b8ff05f4fa0c51a6e4a9e1f3f2691341f8b18b4627fea78192b4819d0d079aaaf1d036e99e1f1c57a5ceebade50c5f42546fc6f0190c4650239897c1d62
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 YOURNAME
1
+ Copyright 2014 Aaron Miler
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,6 +1,56 @@
1
1
  # Mori
2
2
 
3
- ## Badgers
3
+ ### Badgers
4
4
  [![Code Climate](https://codeclimate.com/github/pineworks/mori.png)](https://codeclimate.com/github/pineworks/mori)
5
5
  [![Build Status](https://travis-ci.org/pineworks/mori.png?branch=master)](https://travis-ci.org/pineworks/mori)
6
6
  [![Coverage Status](https://coveralls.io/repos/pineworks/mori/badge.png?branch=master)](https://coveralls.io/r/pineworks/mori?branch=master)
7
+
8
+ Mori is a lightweight Rails Engine built to handle authentication.
9
+
10
+ Mori was built with the intention of being easy to overwrite, and easy to implement.
11
+
12
+ ## Installing
13
+
14
+ Mori is a Rails Engine tested against Rails 3.2+ and Ruby 1.9.3+
15
+
16
+ Include it in your Gemfile
17
+ ``` ruby
18
+ gem 'mori'
19
+ ```
20
+
21
+ Bundle
22
+ ```
23
+ bundle install
24
+ ```
25
+
26
+ After your development database exists, run the generator
27
+ ```
28
+ rails g mori:install
29
+ ```
30
+
31
+ The generator does the following:
32
+ - Inserts Mori::User in your User model
33
+ - Inserts Mori::Controller in your ApplicationController
34
+ - Creates a migration to add missing collumns, or create a new table.
35
+
36
+ ## Configuration
37
+
38
+ Mori comes with configuration options. You can override defaults in `config/initializers/mori.rb`
39
+
40
+ ``` ruby
41
+ Mori.configure do |config|
42
+
43
+ # Mori Default Configuration
44
+
45
+ config.from_email = 'reply@example.com'
46
+ config.app_name = Rails.application.class.parent_name.humanize
47
+ config.allow_sign_up = true
48
+ config.dashboard_path = '/'
49
+ config.after_sign_up_path = '/'
50
+ config.after_logout_path = '/'
51
+ config.token_expiration = 14
52
+ end
53
+
54
+ ```
55
+
56
+
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  begin
2
2
  require 'bundler/setup'
3
+ require 'thor'
3
4
  rescue LoadError
4
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
6
  end
@@ -0,0 +1,3 @@
1
+ class Mori::BaseController < ApplicationController
2
+ layout 'mori/application'
3
+ end
@@ -0,0 +1,37 @@
1
+ class Mori::InvitesController < Mori::BaseController
2
+ before_filter :authenticate!, :only => [:new, :send]
3
+ def show
4
+ @user = Mori.configuration.user_model.find_by_invitation_token(params[:id])
5
+ if @user
6
+ render :template => 'invites/show'
7
+ else
8
+ redirect_to root_path
9
+ end
10
+ end
11
+
12
+ def new
13
+ render :template => 'invites/new'
14
+ end
15
+
16
+ def accept
17
+ config = Mori.configuration
18
+ valid, message = config.user_model.accept_invitation(user_params[:invitation_token], user_params[:password], user_params[:password_confirmation])
19
+ flash[:notice] = message
20
+ if valid
21
+ warden.authenticate!
22
+ redirect_to config.dashboard_path
23
+ else
24
+ redirect_to invite_path(user_params[:invitation_token])
25
+ end
26
+ end
27
+
28
+ def send_user
29
+ valid, message = Mori.configuration.user_model.invite(params[:email])
30
+ flash[:notice] = message
31
+ if valid
32
+ redirect_to Mori.configuration.dashboard_path
33
+ else
34
+ render :template => 'invites/new'
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,59 @@
1
+ class Mori::PasswordsController < Mori::BaseController
2
+ before_filter :authenticate!, :only => :change
3
+ def forgot
4
+ # View for sending password reset
5
+ if current_user
6
+ redirect_to Mori.configuration.dashboard_path
7
+ else
8
+ render :template => 'passwords/forgot'
9
+ end
10
+ end
11
+
12
+ def change
13
+ # View for change password
14
+ render :template => 'passwords/change'
15
+ end
16
+
17
+ def reset
18
+ redirect_to root_path unless params[:token]
19
+ @user = Mori.configuration.user_model.find_by_password_reset_token(params[:token])
20
+ if @user
21
+ render :template => 'passwords/reset'
22
+ else
23
+ redirect_to root_path
24
+ end
25
+ end
26
+
27
+ def send_reset
28
+ # Send Password Reset to User
29
+ if !Mori.configuration.user_model.forgot_password(params[:email])
30
+ render :template => 'passwords/forgot'
31
+ else
32
+ render :template => 'passwords/send_reset'
33
+ end
34
+ end
35
+
36
+ def update
37
+ # Update their password
38
+ valid, message = current_user.change_password(params[:password], params[:new_password], params[:new_password_confirmation])
39
+ if valid
40
+ flash[:notice] = t('flashes.password_changed_successfully')
41
+ redirect_to Mori.configuration.dashboard_path
42
+ else
43
+ flash[:notice] = message
44
+ render :template => 'passwords/change'
45
+ end
46
+ end
47
+
48
+ def reset_password
49
+ valid, message = Mori.configuration.user_model.reset_password(user_params[:password_reset_token], user_params[:password], user_params[:password_confirmation])
50
+ flash[:notice] = message
51
+ if valid
52
+ warden.authenticate!
53
+ redirect_to Mori.configuration.dashboard_path
54
+ else
55
+ flash[:notice] = message
56
+ redirect_to "/passwords/reset?token=#{user_params[:password_reset_token]}"
57
+ end
58
+ end
59
+ end
@@ -1,23 +1,48 @@
1
- class Mori::RegistrationsController < MoriController
1
+ class Mori::RegistrationsController < Mori::BaseController
2
2
  def new
3
3
  if current_user
4
- redirect_to Mori.configuration.after_login_url
4
+ redirect_to Mori.configuration.dashboard_path
5
+ else
6
+ @user = Mori.configuration.user_model.new
7
+ render :template => 'registrations/new'
5
8
  end
6
- @user = Mori::User.new
7
9
  end
8
10
 
9
11
  def create
10
- @user = Mori::User.new(user_params)
12
+ @user = user_from_params
11
13
  if @user.save
12
14
  warden.set_user(@user)
13
- redirect_to Mori.configuration.after_signup_url
15
+ redirect_to Mori.configuration.after_sign_up_path
16
+ else
17
+ flash[:notice] = @user.errors.map { |k, v| "#{k} #{v}" }.join(' and ').humanize
18
+ render :template => 'registrations/new'
19
+ end
20
+ end
21
+
22
+ def confirmation
23
+ valid, message = Mori.configuration.user_model.confirm_email(params[:token])
24
+ if valid
25
+ flash[:notice] = message
26
+ redirect_to Mori.configuration.dashboard_path
14
27
  else
15
- render "new"
28
+ flash[:notice] = message
29
+ redirect_to root_path
16
30
  end
17
31
  end
32
+
18
33
  private
19
34
 
35
+ def user_from_params
36
+ email = user_params.delete(:email)
37
+ password = user_params.delete(:password)
38
+
39
+ Mori.configuration.user_model.new().tap do |user|
40
+ user.email = email
41
+ user.password = password
42
+ end
43
+ end
44
+
20
45
  def user_params
21
- params.require(:mori_user).permit(:username, :email, :password)
46
+ params[:user] || Hash.new
22
47
  end
23
48
  end
@@ -1,17 +1,21 @@
1
- class Mori::SessionsController < MoriController
1
+ class Mori::SessionsController < Mori::BaseController
2
2
  def new
3
- redirect_to Mori.configuration.after_login_url if current_user
4
- @user = Mori::User.new
5
- flash.now.alert = warden.message if warden.message.present?
3
+ if current_user
4
+ redirect_to Mori.configuration.dashboard_path
5
+ else
6
+ @user = Mori.configuration.user_model.new
7
+ flash.now.alert = warden.message if warden.message.present?
8
+ render :template => 'sessions/new'
9
+ end
6
10
  end
7
11
 
8
12
  def create
9
13
  warden.authenticate!
10
- redirect_to Mori.configuration.after_login_url, notice: "You have logged in"
14
+ redirect_to Mori.configuration.dashboard_path, :notice => 'You have logged in'
11
15
  end
12
16
 
13
17
  def destroy
14
18
  warden.logout
15
- redirect_to Mori.configuration.after_logout_url
19
+ redirect_to Mori.configuration.after_logout_path
16
20
  end
17
21
  end
@@ -1,5 +1,5 @@
1
1
  module MoriHelper
2
- def logout_link(text="Log Out")
2
+ def logout_link(text = 'Log Out')
3
3
  link_to text, logout_path, :method => :delete
4
4
  end
5
5
  end
@@ -0,0 +1,18 @@
1
+ class MoriMailer < ActionMailer::Base
2
+ default :from => Mori.configuration.from_email
3
+
4
+ def forgot_password(user)
5
+ @user = user
6
+ mail(:to => user.email, :subject => "Your password on #{Mori.configuration.app_name} has been reset")
7
+ end
8
+
9
+ def invite_user(user)
10
+ @user = user
11
+ mail(:to => user.email, :subject => "You've been invited to #{Mori.configuration.app_name}")
12
+ end
13
+
14
+ def confirm_email(user)
15
+ @user = user
16
+ mail(:to => user.email, :subject => "Please confirm your email on #{Mori.configuration.app_name}")
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ <%= render :partial => 'mori_forms/invite_new_user_form' %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'mori_forms/accept_invite' %>
@@ -8,7 +8,13 @@
8
8
  </head>
9
9
  <body>
10
10
 
11
- <%= yield %>
11
+ <div class="container">
12
+ <div class="row">
13
+ <div class="form-wrap col-md-4 col-md-offset-4">
14
+ <%= yield %>
15
+ </div>
16
+ </div>
17
+ </div>
12
18
 
13
19
  </body>
14
20
  </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Mori</title>
5
+ <%= stylesheet_link_tag "mori/application", media: "all" %>
6
+ <%= javascript_include_tag "mori/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <%= yield %>
12
+ </div>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,16 @@
1
+ <%= form_for @user, :url => accept_invites_path, :method => :put, :id => 'accept_invites_form', :class => 'mori_form' do |f| %>
2
+ <h3 class="form-title">Accept Invitation</h3>
3
+ <h4><%= flash[:notice] %></h4>
4
+ <%= f.hidden_field :invitation_token %>
5
+ <%= f.hidden_field :email %>
6
+ <div class="form-group">
7
+ <%= f.label :password %>
8
+ <%= f.password_field :password, :class => "form-control" %>
9
+ </div>
10
+ <div class="form-group">
11
+ <%= f.label :password_confirmation %>
12
+ <%= f.password_field :password_confirmation, :class => "form-control" %>
13
+ </div>
14
+ <%= f.button "Accept", :type => :submit, :class => "btn btn-primary" %>
15
+
16
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <%= form_tag passwords_path, :method => :post, :id => "password_change_form", :class => 'mori_form' do %>
2
+ <h3 class="form-title">Change Password</h3>
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:notice] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <div class="form-group">
10
+ <%= label_tag "Current Password" %>
11
+ <%= password_field_tag :password, "", :class => "form-control" %>
12
+ </div>
13
+ <div class="form-group">
14
+ <%= label_tag "New Password" %>
15
+ <%= password_field_tag :new_password, "", :class => "form-control" %>
16
+ </div>
17
+ <div class="form-group">
18
+ <%= label_tag "Confirm New Password" %>
19
+ <%= password_field_tag :new_password_confirmation, "", :class => "form-control" %>
20
+ </div>
21
+ <%= button_tag "Change Password", :type => :submit, :class => "btn btn-primary" %>
22
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= form_tag send_reset_passwords_path, :id => "forgot_password_form", :class => 'mori-form' do %>
2
+ <h3 class="form-title">Reset My Password</h3>
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:notice] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <div class="form-group">
10
+ <%= label_tag "Email" %>
11
+ <%= text_field_tag :email, "", :class => "form-control" %>
12
+ </div>
13
+ <%= button_tag "Reset Password", :type => :submit, :class => "btn btn-primary" %>
14
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= form_tag send_user_invites_path, :id => "invite_new_user_form", :class => 'mori-form' do %>
2
+ <h3 class="form-title">Invite New User</h3>
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:notice] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <div class="form-group">
10
+ <%= label_tag :email, "E-mail" %>
11
+ <%= text_field_tag :email,"", :class => 'form-control' %>
12
+ </div>
13
+ <%= button_tag "Invite User", :type => :submit, :class => "btn btn-primary" %>
14
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <%= form_for @user, :url => reset_password_passwords_path, :method => :post, :class => 'mori-form' do |f| %>
2
+ <h3 class="form-title">Reset Password</h3>
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:notice] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <%= f.hidden_field :email %>
10
+ <%= f.hidden_field :password_reset_token %>
11
+ <div class="form-group">
12
+ <%= f.label :password, "New Password" %>
13
+ <%= f.password_field :password, :class => "form-control" %>
14
+ </div>
15
+ <div class="form-group">
16
+ <%= f.label :password, "Confirm Password" %>
17
+ <%= f.password_field :password_confirmation, :class => "form-control" %>
18
+ </div>
19
+ <%= f.button "Update Password", :type => :submit, :class => "btn btn-primary" %>
20
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <%= form_for @user, :url => registrations_path, :method => :post, :class => 'mori-form' do |f| %>
2
+ <h3 class="form-title">Sign Up</h3>
3
+ <% if flash[:notice] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:notice] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <div class="form-group">
10
+ <%= f.label :email %>
11
+ <%= f.text_field :email, :class => 'form-control' %>
12
+ </div>
13
+ <div class="form-group">
14
+ <%= f.label :password %>
15
+ <%= f.password_field :password, :class => 'form-control' %>
16
+ </div>
17
+ <div class="form-group">
18
+ <%= f.label :password_confirmation %>
19
+ <%= f.password_field :password_confirmation, :class => 'form-control' %>
20
+ </div>
21
+ <%= f.button "Sign Up", :type => :submit, :class => "btn btn-primary" %>
22
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <%= form_for @user, :url => sessions_path, :method => :post, :html => { :id => "new_session", :class => 'mori-form'} do |f| %>
2
+ <h3 class="form-title">Log In</h3>
3
+ <% if flash[:alert] %>
4
+ <div class="alert alert-danger alert-dismissable">
5
+ <%= flash[:alert] %>
6
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
7
+ </div>
8
+ <% end %>
9
+ <div class="form-group">
10
+ <%= f.label :email %>
11
+ <%= f.text_field :email, :class => "form-control" %>
12
+ </div>
13
+ <div class="form-group">
14
+ <%= f.label :password %>
15
+ <%= f.password_field :password, :class => "form-control" %>
16
+ </div>
17
+ <%= f.button "Log In", :type => :submit, :class => "btn btn-primary" %>
18
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <p><%=t 'emails.confirm.opening', :app_name => Mori.configuration.app_name %></p>
2
+ <p><%=t 'emails.confirm.intro' %></p>
3
+ <%= link_to('Confirm Your Email', confirmation_registrations_url(:token => @user.confirmation_token)) %>
4
+ <p><%=t 'emails.confirm.closing', :app_name => Mori.configuration.app_name %></p>
@@ -0,0 +1,7 @@
1
+ <p> <%=t 'emails.forgot.opening', :app_name => Mori.configuration.app_name %> </p>
2
+ <p> <%=t 'emails.forgot.intro' %></p>
3
+ <p> <%= link_to('Reset Password', forgot_passwords_url(:token => @user.password_reset_token)) %> </p>
4
+ <p> <%=t 'emails.forgot.closing' %></p>
5
+ <p>
6
+ If you did not do this, disregard this email
7
+ </p>
@@ -0,0 +1,5 @@
1
+ <p><%=t 'emails.invite.opening', :app_name => Mori.configuration.app_name %></p>
2
+
3
+ <%= link_to invite_url(:id => @user.invitation_token), "Accept Invitation" %>
4
+
5
+ <p><%=t 'emails.invite.closing' %></p>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'mori_forms/change_password' %>
@@ -0,0 +1,2 @@
1
+ <%= render :partial => 'mori_forms/forgot_password' %>
2
+ <%= render :partial => 'shared/links' %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'mori_forms/password_reset' %>
@@ -0,0 +1 @@
1
+ <h1> Password Reset Sent </h1>
@@ -0,0 +1,2 @@
1
+ <%= render :partial => 'mori_forms/registration' %>
2
+ <%= render :partial => 'shared/links' %>
@@ -0,0 +1,2 @@
1
+ <%= render :partial => 'mori_forms/sessions' %>
2
+ <%= render :partial => 'shared/links' %>
@@ -0,0 +1,11 @@
1
+ <ul class="mori-links">
2
+ <% if controller_name != 'sessions' %>
3
+ <li><%= link_to "Sign In", login_path %></li>
4
+ <% end %>
5
+ <% if controller_name != 'registrations' %>
6
+ <li><%= link_to "Sign Up", sign_up_path %></li>
7
+ <% end %>
8
+ <% if controller_name != 'passwords' && controller_name != 'registrations' %>
9
+ <li><%= link_to "Forgot your password?", forgot_passwords_path %></li>
10
+ <% end %>
11
+ </ul>
@@ -1,27 +1,5 @@
1
- postgresql: &postgresql
2
- adapter: postgresql
3
- username: postgres
4
- password:
5
- database: mori_<%= Rails.env %>
6
- min_messages: ERROR
7
-
8
- user:
9
- adapter: postgresql
10
- username: postgres
11
- password:
12
- database: mori_users
13
-
14
- defaults: &defaults
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
15
4
  pool: 5
16
5
  timeout: 5000
17
- host: localhost
18
- <<: *<%= ENV['DB'] || "postgresql" %>
19
-
20
- development:
21
- <<: *defaults
22
-
23
- test:
24
- <<: *defaults
25
-
26
- production:
27
- <<: *defaults
@@ -8,20 +8,20 @@ Warden::Manager.serialize_into_session do |user|
8
8
  end
9
9
 
10
10
  Warden::Manager.serialize_from_session do |id|
11
- Mori::User.find(id)
11
+ Mori.configuration.user_model.find(id)
12
12
  end
13
13
 
14
14
  Warden::Strategies.add(:password) do
15
15
  def valid?
16
- params['mori_user']['email'] and params['mori_user']['password']
16
+ params['user'].present? and params['user']['email'] and params['user']['password']
17
17
  end
18
18
 
19
19
  def authenticate!
20
- user = Mori::User.find_by_email(params['mori_user']['email'])
21
- if user and user.authenticate(params['mori_user']['password'])
20
+ user = User.find_by_email(params['user']['email'])
21
+ if user and user.authenticate(params['user']['password'])
22
22
  success! user
23
23
  else
24
- fail "Invalid login credentials"
24
+ fail! "Invalid login credentials"
25
25
  end
26
26
  end
27
27
  end
@@ -1,17 +1,21 @@
1
1
  en:
2
- mori_mailer:
3
- confirm_email:
4
- opening:
5
- "Welcome to %{application_name}"
6
- intro:
7
- "Please note that some actions will require you to have a confirmed email. Follow the link below to confirm your email"
8
- closing:
9
- "If you didn't sign up for %{application_name}, please ignore this email"
10
- invitation_email:
11
- opening:
12
- "You've been invited to %{application_name}"
13
- intro:
14
- "Follow the link below to accept the invitation"
15
- closing:
16
- "If you don't wish to accept the invitation to %{application_name}, simply ignore this email"
17
-
2
+ flashes:
3
+ passwords_did_not_match: Your passwords did not match, please try again
4
+ password_change_failed: We were unable to reset your password. Please try again
5
+ password_changed_sucessfully: Your password has been updated
6
+ password_has_been_reset: Your password has been reset
7
+ could_not_invite_user: Could not invite user
8
+ accepted_invitation_message: You have accepted the invitation, welcome magical user
9
+ logged_in: You have logged in
10
+ emails:
11
+ forgot:
12
+ opening: You have requested to reset your password on %{app_name}
13
+ intro: Please follow the link below and you can change your password
14
+ closing: If you did not request this, ignore this email. Your password has not been changed.
15
+ invite:
16
+ opening: You have been invited to %{app_name}, to accept the invitation click the link below
17
+ closing: To decline this invitation simply ignore this email.
18
+ confirm:
19
+ opening: Welcome to %{app_name}
20
+ intro: Please note that some actions will require you to have a confirmed email. Follow the link below to confirm your email
21
+ closing: If you didn't sign up for %{app_name}, please ignore this email