mori 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +51 -1
- data/Rakefile +1 -0
- data/app/controllers/mori/base_controller.rb +3 -0
- data/app/controllers/mori/invites_controller.rb +37 -0
- data/app/controllers/mori/passwords_controller.rb +59 -0
- data/app/controllers/mori/registrations_controller.rb +32 -7
- data/app/controllers/mori/sessions_controller.rb +10 -6
- data/app/helpers/mori_helper.rb +1 -1
- data/app/mailers/mori_mailer.rb +18 -0
- data/app/views/invites/new.html.erb +1 -0
- data/app/views/invites/show.html.erb +1 -0
- data/app/views/layouts/mori/application.html.erb +7 -1
- data/app/views/layouts/mori/form.html.erb +15 -0
- data/app/views/mori_forms/_accept_invite.html.erb +16 -0
- data/app/views/mori_forms/_change_password.html.erb +22 -0
- data/app/views/mori_forms/_forgot_password.html.erb +14 -0
- data/app/views/mori_forms/_invite_new_user_form.html.erb +14 -0
- data/app/views/mori_forms/_password_reset.html.erb +20 -0
- data/app/views/mori_forms/_registration.html.erb +22 -0
- data/app/views/mori_forms/_sessions.html.erb +18 -0
- data/app/views/mori_mailer/confirm_email.html.erb +4 -0
- data/app/views/mori_mailer/forgot_password.html.erb +7 -0
- data/app/views/mori_mailer/invite_user.html.erb +5 -0
- data/app/views/passwords/change.html.erb +1 -0
- data/app/views/passwords/forgot.html.erb +2 -0
- data/app/views/passwords/reset.html.erb +1 -0
- data/app/views/passwords/send_reset.html.erb +1 -0
- data/app/views/registrations/new.html.erb +2 -0
- data/app/views/sessions/new.html.erb +2 -0
- data/app/views/shared/_links.html.erb +11 -0
- data/config/database.travis.yml +3 -25
- data/config/initializers/warden.rb +5 -5
- data/config/locales/mori.en.yml +20 -16
- data/config/routes.rb +22 -2
- data/db/migrate/20140128055658_create_users.rb +29 -0
- data/lib/assets/javascripts/bootstrap.min.js +6 -0
- data/lib/assets/stylesheets/bootstrap.min.css +7 -0
- data/lib/generators/mori/install/install_generator.rb +130 -0
- data/lib/generators/mori/install/templates/db/migrate/add_mori_to_users.rb +23 -0
- data/{db/migrate/20140128055658_create_mori_users.rb → lib/generators/mori/install/templates/db/migrate/create_users.rb} +6 -9
- data/lib/generators/mori/install/templates/mori.rb +32 -0
- data/lib/generators/mori/install/templates/user.rb +3 -0
- data/lib/generators/mori/views/USAGE +12 -0
- data/lib/generators/mori/views/views_generator.rb +39 -0
- data/lib/mori/configuration.rb +17 -10
- data/lib/mori/controller.rb +25 -0
- data/lib/mori/engine.rb +2 -6
- data/lib/mori/password.rb +21 -0
- data/lib/mori/token.rb +3 -12
- data/lib/mori/user.rb +124 -0
- data/lib/mori/version.rb +1 -1
- data/lib/mori.rb +3 -3
- data/spec/dummy/app/assets/javascripts/application.js +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/app/views/application/index.html.erb +13 -0
- data/spec/dummy/app/views/application/test_login.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/config/application.rb +9 -7
- data/spec/dummy/config/database.yml +6 -24
- data/spec/dummy/config/environments/production.rb +2 -2
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config/initializers/mime_types.rb +2 -2
- data/spec/dummy/config/initializers/mori.rb +12 -1
- data/spec/dummy/config/initializers/secret_token.rb +6 -1
- data/spec/dummy/config/locales/en.yml +1 -1
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/{20140209071716_create_users.mori_engine.rb → 20140421045106_create_users.mori_engine.rb} +2 -6
- data/spec/dummy/db/schema.rb +14 -21
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +14442 -21478
- data/spec/dummy/log/test.log +128933 -76950
- data/spec/dummy/public/404.html +1 -1
- data/spec/dummy/public/422.html +1 -1
- data/spec/dummy/public/500.html +1 -1
- data/spec/dummy/tmp/cache/assets/development/sprockets/07db4022ed50ebf1535599a3e2344037 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/09f817f5fe8888d5c59a3b285c3ef605 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/19f899de0e04ccfd931a7a11e36aca13 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1b98ef3337306536c2890a74951d225c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2000a2ad47f8e201455b785beb7b1384 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/22de1150643c428d3f508171d74347a3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3453364cd811fec54cae0a92adc719e4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4462cfec451130aa58d88b3da13913c3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/45753608d28d02693f8f6277074589a1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/56b349da612a4be9d5e6733778ce17e4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5b3ef4ce70e1da7b1afd392754613726 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/770ff8b64985dd08cab8c32a1fa76438 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8e4cef792c949716da8fe3e9ee0cda70 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6374c002de146da5c25b8cfd375ce6c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b085c718dd9381a5d4036f00b47d1b91 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c207a30f2b33f7df2c5336aed05485a2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf4d7483cd5aff334d69dd3173f9b953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e2b0bfc208732a6cf47d67c1be32e54f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/07db4022ed50ebf1535599a3e2344037 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/09f817f5fe8888d5c59a3b285c3ef605 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1143c7a241c19613744d1a2be3ad7cd1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/19f899de0e04ccfd931a7a11e36aca13 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1b98ef3337306536c2890a74951d225c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/39cd89cab4906d24583c876a477cf098 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4462cfec451130aa58d88b3da13913c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/45753608d28d02693f8f6277074589a1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/56b349da612a4be9d5e6733778ce17e4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5b3ef4ce70e1da7b1afd392754613726 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/770ff8b64985dd08cab8c32a1fa76438 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8e4cef792c949716da8fe3e9ee0cda70 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9d5b4060cdb29606bd153ef2ca742a22 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a6374c002de146da5c25b8cfd375ce6c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b085c718dd9381a5d4036f00b47d1b91 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c1fb58de0c271425746c77af9e101750 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c207a30f2b33f7df2c5336aed05485a2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e2b0bfc208732a6cf47d67c1be32e54f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/factories/mori_users.rb +8 -8
- data/spec/features/invites_spec.rb +64 -0
- data/spec/features/passwords_spec.rb +101 -0
- data/spec/features/registrations_spec.rb +37 -10
- data/spec/features/sessions_spec.rb +24 -28
- data/spec/helpers/mori_helper_spec.rb +3 -12
- data/spec/helpers.rb +10 -0
- data/spec/mailers/mori/mailer_spec.rb +24 -4
- data/spec/models/mori/user_spec.rb +187 -167
- data/spec/spec_helper.rb +17 -6
- metadata +108 -53
- data/app/assets/javascripts/mori/application.js +0 -13
- data/app/assets/stylesheets/mori/application.css +0 -13
- data/app/controllers/mori_controller.rb +0 -8
- data/app/mailers/mori/mailer.rb +0 -17
- data/app/models/mori/user.rb +0 -85
- data/app/views/mori/mailer/confirm_email.html.erb +0 -1
- data/app/views/mori/mailer/invite_user.html.erb +0 -1
- data/app/views/mori/mailer/password_reset_notification.html.erb +0 -1
- data/app/views/mori/registrations/new.slim +0 -9
- data/app/views/mori/sessions/new.slim +0 -8
- data/db/migrate/20140126052000_enable_hstore.rb +0 -9
- data/lib/mori/string.rb +0 -20
- data/spec/dummy/app/views/application/index.slim +0 -2
- data/spec/dummy/db/migrate/20140128055553_enable_hstore.mori.rb +0 -10
- data/spec/dummy/log/user.log +0 -43
- data/spec/dummy/tmp/pids/server.pid +0 -1
- data/spec/mailer_matcher.rb +0 -33
- data/spec/views/mori/registrations/create.html.erb_spec.rb +0 -5
- data/spec/views/mori/registrations/new.html.erb_spec.rb +0 -5
- data/spec/views/mori/sessions/create.html.erb_spec.rb +0 -5
- data/spec/views/mori/sessions/destroy.html.erb_spec.rb +0 -5
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e216ffc7bd86384021962479ecd4fc801a2c820e
|
|
4
|
+
data.tar.gz: 2a15f5d7f9d804ce568dbcc5d80a52ed31ba6648
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05baff8ea62aac281ca8e652328ef7cec128d6bfb7544bc61b277f265020d850a1f1a6b524cf4e52cf3a548f33dd6d5f07faf09e40eddc5f5308649f4e26c123
|
|
7
|
+
data.tar.gz: ea8d7b8ff05f4fa0c51a6e4a9e1f3f2691341f8b18b4627fea78192b4819d0d079aaaf1d036e99e1f1c57a5ceebade50c5f42546fc6f0190c4650239897c1d62
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
# Mori
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Badgers
|
|
4
4
|
[](https://codeclimate.com/github/pineworks/mori)
|
|
5
5
|
[](https://travis-ci.org/pineworks/mori)
|
|
6
6
|
[](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
|
@@ -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 <
|
|
1
|
+
class Mori::RegistrationsController < Mori::BaseController
|
|
2
2
|
def new
|
|
3
3
|
if current_user
|
|
4
|
-
redirect_to Mori.configuration.
|
|
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 =
|
|
12
|
+
@user = user_from_params
|
|
11
13
|
if @user.save
|
|
12
14
|
warden.set_user(@user)
|
|
13
|
-
redirect_to Mori.configuration.
|
|
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
|
-
|
|
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
|
|
46
|
+
params[:user] || Hash.new
|
|
22
47
|
end
|
|
23
48
|
end
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
class Mori::SessionsController <
|
|
1
|
+
class Mori::SessionsController < Mori::BaseController
|
|
2
2
|
def new
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.
|
|
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.
|
|
19
|
+
redirect_to Mori.configuration.after_logout_path
|
|
16
20
|
end
|
|
17
21
|
end
|
data/app/helpers/mori_helper.rb
CHANGED
|
@@ -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' %>
|
|
@@ -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">×</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">×</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">×</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">×</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">×</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">×</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 @@
|
|
|
1
|
+
<%= render :partial => 'mori_forms/change_password' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render :partial => 'mori_forms/password_reset' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1> Password Reset Sent </h1>
|
|
@@ -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>
|
data/config/database.travis.yml
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
adapter:
|
|
3
|
-
|
|
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
|
|
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['
|
|
16
|
+
params['user'].present? and params['user']['email'] and params['user']['password']
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def authenticate!
|
|
20
|
-
user =
|
|
21
|
-
if user and user.authenticate(params['
|
|
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
|
data/config/locales/mori.en.yml
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
en:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
intro:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|