mori 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +6 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/mori/application.js +13 -0
- data/app/assets/stylesheets/mori/application.css +13 -0
- data/app/controllers/mori/registrations_controller.rb +23 -0
- data/app/controllers/mori/sessions_controller.rb +17 -0
- data/app/controllers/mori_controller.rb +8 -0
- data/app/helpers/mori_helper.rb +5 -0
- data/app/mailers/mori/mailer.rb +17 -0
- data/app/models/mori/user.rb +85 -0
- data/app/views/layouts/mori/application.html.erb +14 -0
- data/app/views/mori/mailer/confirm_email.html.erb +1 -0
- data/app/views/mori/mailer/invite_user.html.erb +1 -0
- data/app/views/mori/mailer/password_reset_notification.html.erb +1 -0
- data/app/views/mori/registrations/new.slim +9 -0
- data/app/views/mori/sessions/new.slim +8 -0
- data/config/database.travis.yml +27 -0
- data/config/initializers/warden.rb +27 -0
- data/config/locales/mori.en.yml +17 -0
- data/config/mori.en.yml +0 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20140126052000_enable_hstore.rb +9 -0
- data/db/migrate/20140128055658_create_mori_users.rb +33 -0
- data/lib/mori.rb +12 -0
- data/lib/mori/configuration.rb +36 -0
- data/lib/mori/engine.rb +19 -0
- data/lib/mori/string.rb +20 -0
- data/lib/mori/token.rb +16 -0
- data/lib/mori/version.rb +3 -0
- data/lib/tasks/mori_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/application/index.slim +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +48 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/mori.rb +3 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/migrate/20140128055553_enable_hstore.mori.rb +10 -0
- data/spec/dummy/db/migrate/20140209071716_create_users.mori_engine.rb +34 -0
- data/spec/dummy/db/schema.rb +39 -0
- data/spec/dummy/log/development.log +25025 -0
- data/spec/dummy/log/test.log +79149 -0
- data/spec/dummy/log/user.log +43 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/07db4022ed50ebf1535599a3e2344037 +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/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +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/a6374c002de146da5c25b8cfd375ce6c +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/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/07db4022ed50ebf1535599a3e2344037 +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/56b349da612a4be9d5e6733778ce17e4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5b3ef4ce70e1da7b1afd392754613726 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a6374c002de146da5c25b8cfd375ce6c +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/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/factories/mori_users.rb +16 -0
- data/spec/features/registrations_spec.rb +23 -0
- data/spec/features/sessions_spec.rb +31 -0
- data/spec/helpers/mori_helper_spec.rb +15 -0
- data/spec/mailer_matcher.rb +33 -0
- data/spec/mailers/mori/mailer_spec.rb +7 -0
- data/spec/models/mori/user_spec.rb +195 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/views/mori/registrations/create.html.erb_spec.rb +5 -0
- data/spec/views/mori/registrations/new.html.erb_spec.rb +5 -0
- data/spec/views/mori/sessions/create.html.erb_spec.rb +5 -0
- data/spec/views/mori/sessions/destroy.html.erb_spec.rb +5 -0
- data/spec/views/mori/sessions/new.html.erb_spec.rb +5 -0
- metadata +298 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 0ee64fc60f4aa320446d6cddccf5be8fa3bbf432
|
|
4
|
+
data.tar.gz: 0702dbfb25aec136a1f6bb806efb41001a487922
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 941665ac96f3de8512dfc6c0d4cf73eae75dccd3d725ca1ef6176331df94d7f9e5720ed96d13ad13246643a989f17e7f33a964494d931809a3187b4521d1e8d7
|
|
7
|
+
data.tar.gz: 0ce4f4f2fc046f623ba0368ba74a9faa6b10eee0254f07d40bc857df081a7a53b86cd3241c7922ffee5989f959f0b8e5724a7eecf905a74141ffedf23b573bf8
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2014 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Mori
|
|
2
|
+
|
|
3
|
+
## Badgers
|
|
4
|
+
[](https://codeclimate.com/github/pineworks/mori)
|
|
5
|
+
[](https://travis-ci.org/pineworks/mori)
|
|
6
|
+
[](https://coveralls.io/r/pineworks/mori?branch=master)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Mori'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
Bundler::GemHelper.install_tasks
|
|
21
|
+
|
|
22
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
|
23
|
+
|
|
24
|
+
require 'rspec/core'
|
|
25
|
+
require 'rspec/core/rake_task'
|
|
26
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
|
27
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
|
28
|
+
|
|
29
|
+
task :default => :spec
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Mori::RegistrationsController < MoriController
|
|
2
|
+
def new
|
|
3
|
+
if current_user
|
|
4
|
+
redirect_to Mori.configuration.after_login_url
|
|
5
|
+
end
|
|
6
|
+
@user = Mori::User.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
@user = Mori::User.new(user_params)
|
|
11
|
+
if @user.save
|
|
12
|
+
warden.set_user(@user)
|
|
13
|
+
redirect_to Mori.configuration.after_signup_url
|
|
14
|
+
else
|
|
15
|
+
render "new"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def user_params
|
|
21
|
+
params.require(:mori_user).permit(:username, :email, :password)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Mori::SessionsController < MoriController
|
|
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?
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
warden.authenticate!
|
|
10
|
+
redirect_to Mori.configuration.after_login_url, notice: "You have logged in"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def destroy
|
|
14
|
+
warden.logout
|
|
15
|
+
redirect_to Mori.configuration.after_logout_url
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Mori
|
|
2
|
+
class Mailer < ActionMailer::Base
|
|
3
|
+
default from: Mori.configuration.from_email
|
|
4
|
+
|
|
5
|
+
def password_reset_notification(user)
|
|
6
|
+
@user = user
|
|
7
|
+
mail(to: user.email, subject: "Your password on #{Mori.configuration.application_name} has been reset")
|
|
8
|
+
end
|
|
9
|
+
def invite_user(user)
|
|
10
|
+
@user = user
|
|
11
|
+
mail(to: user.email, subject: "You've been invited to #{Mori.configuration.application_name}")
|
|
12
|
+
end
|
|
13
|
+
def confirm_email(user)
|
|
14
|
+
@user = user
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require 'email_validator'
|
|
2
|
+
|
|
3
|
+
module Mori
|
|
4
|
+
include BCrypt
|
|
5
|
+
class User < ActiveRecord::Base
|
|
6
|
+
include Mori::Token
|
|
7
|
+
|
|
8
|
+
if Mori.configuration.account_database
|
|
9
|
+
establish_connection Mori.configuration.account_database
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
validates :email, email: { strict_mode: true }, presence: true, uniqueness: true
|
|
13
|
+
validates :password, presence: true, unless: :invitation_token?
|
|
14
|
+
validates :password_reset_token, uniqueness: true, if: :password_reset_token?
|
|
15
|
+
validates :invitation_token, uniqueness: true, if: :invitation_token?
|
|
16
|
+
|
|
17
|
+
before_save :encrypt_password, :if => Proc.new { |user| user.password_changed? }
|
|
18
|
+
before_validation :normalize_email, :if => Proc.new{ |user| user.email_changed? }
|
|
19
|
+
before_create :send_email_confirmation, :if => Proc.new { |user| user.password.present? }
|
|
20
|
+
|
|
21
|
+
# Methods called by ActiveRecord
|
|
22
|
+
|
|
23
|
+
def encrypt_password
|
|
24
|
+
self.password = self.password.encrypt
|
|
25
|
+
end
|
|
26
|
+
def normalize_email
|
|
27
|
+
self.email = self.email.normalize
|
|
28
|
+
end
|
|
29
|
+
def send_email_confirmation
|
|
30
|
+
self.confirmation_token = SecureRandom.hex(25)
|
|
31
|
+
self.confirmation_sent = Date.today
|
|
32
|
+
Mailer.confirm_email(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def accept_invitation(token,new_password)
|
|
36
|
+
user = User.find_by_invitation_token(token)
|
|
37
|
+
raise 'Expired Invitation Token' if user.invitation_sent < Date.today - 2.weeks
|
|
38
|
+
user.password = new_password
|
|
39
|
+
user.save
|
|
40
|
+
user
|
|
41
|
+
end
|
|
42
|
+
def reset_password(token,new_password)
|
|
43
|
+
raise 'Invalid Password Reset Token' unless token == self.password_reset_token
|
|
44
|
+
raise 'Expired Reset Token' if self.password_reset_sent < Date.today - 2.weeks
|
|
45
|
+
self.password = new_password
|
|
46
|
+
self.save
|
|
47
|
+
self
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.invite(email)
|
|
51
|
+
user = User.create({:email => email, :invitation_token => generate_token, :invitation_sent => Date.today})
|
|
52
|
+
Mailer.invite_user(user)
|
|
53
|
+
end
|
|
54
|
+
def self.forgot_password(email)
|
|
55
|
+
user = User.find_by_email(email)
|
|
56
|
+
user.password_reset_token = generate_token
|
|
57
|
+
user.password_reset_sent = Date.today
|
|
58
|
+
Mailer.password_reset_notification(user)
|
|
59
|
+
user.save
|
|
60
|
+
end
|
|
61
|
+
def self.change_password(email, password, new_password)
|
|
62
|
+
user = User.find_by_normalized_email(email.normalize)
|
|
63
|
+
raise "Passwords do not match" if ::BCrypt::Password.new(user.password) != password
|
|
64
|
+
user.password = new_password
|
|
65
|
+
user.save
|
|
66
|
+
user
|
|
67
|
+
end
|
|
68
|
+
def self.confirm_email(email, token)
|
|
69
|
+
user = User.find_by_confirmation_token(token)
|
|
70
|
+
raise 'Invalid Confirmation Token' if user.blank?
|
|
71
|
+
raise 'Expired Confirmation Token' if user.confirmation_sent < Date.today - 2.weeks
|
|
72
|
+
user.confirmed = true
|
|
73
|
+
user.save
|
|
74
|
+
user
|
|
75
|
+
end
|
|
76
|
+
def authenticate(password)
|
|
77
|
+
raise 'Invalid Login' if ::BCrypt::Password.new(self.password) != password
|
|
78
|
+
true
|
|
79
|
+
end
|
|
80
|
+
protected
|
|
81
|
+
def self.find_by_normalized_email(email)
|
|
82
|
+
User.find_by_email(email.normalize)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
h1 Hilo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1> I'm the invitation email </h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I am email!
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
15
|
+
pool: 5
|
|
16
|
+
timeout: 5000
|
|
17
|
+
host: localhost
|
|
18
|
+
<<: *<%= ENV['DB'] || "postgresql" %>
|
|
19
|
+
|
|
20
|
+
development:
|
|
21
|
+
<<: *defaults
|
|
22
|
+
|
|
23
|
+
test:
|
|
24
|
+
<<: *defaults
|
|
25
|
+
|
|
26
|
+
production:
|
|
27
|
+
<<: *defaults
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Rails.application.config.middleware.use Warden::Manager do |manager|
|
|
2
|
+
manager.default_strategies :password
|
|
3
|
+
manager.failure_app = Mori::SessionsController.action(:new)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Warden::Manager.serialize_into_session do |user|
|
|
7
|
+
user.id
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Warden::Manager.serialize_from_session do |id|
|
|
11
|
+
Mori::User.find(id)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Warden::Strategies.add(:password) do
|
|
15
|
+
def valid?
|
|
16
|
+
params['mori_user']['email'] and params['mori_user']['password']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def authenticate!
|
|
20
|
+
user = Mori::User.find_by_email(params['mori_user']['email'])
|
|
21
|
+
if user and user.authenticate(params['mori_user']['password'])
|
|
22
|
+
success! user
|
|
23
|
+
else
|
|
24
|
+
fail "Invalid login credentials"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
data/config/mori.en.yml
ADDED
|
File without changes
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
resources :registrations, :controller => 'mori/registrations', :only => [:new, :create]
|
|
3
|
+
resources :sessions, :controller => 'mori/sessions', :only => [:new, :create, :destroy]
|
|
4
|
+
get '/login' => 'mori/sessions#new', :as => 'login'
|
|
5
|
+
delete '/logout' => 'mori/sessions#destroy', :as => 'logout'
|
|
6
|
+
if Mori.configuration.allow_sign_up?
|
|
7
|
+
get '/sign_up' => 'mori/registrations#new', :as => 'sign_up'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class CreateMoriUsers < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :mori_users do |t|
|
|
4
|
+
|
|
5
|
+
t.string :email
|
|
6
|
+
t.text :password
|
|
7
|
+
|
|
8
|
+
# Invite Related
|
|
9
|
+
t.string :invitation_token
|
|
10
|
+
t.datetime :invitation_sent
|
|
11
|
+
|
|
12
|
+
# Password Reset
|
|
13
|
+
t.string :password_reset_token
|
|
14
|
+
t.datetime :password_reset_sent
|
|
15
|
+
|
|
16
|
+
# Confirmable
|
|
17
|
+
t.boolean :confirmed
|
|
18
|
+
t.string :confirmation_token
|
|
19
|
+
t.datetime :confirmation_sent
|
|
20
|
+
|
|
21
|
+
# Group Relation
|
|
22
|
+
t.integer :group_id
|
|
23
|
+
|
|
24
|
+
# Application specific attributes
|
|
25
|
+
t.hstore :data, :default => {}
|
|
26
|
+
|
|
27
|
+
t.timestamps
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
add_index :mori_users, :email
|
|
31
|
+
add_index :mori_users, :group_id
|
|
32
|
+
end
|
|
33
|
+
end
|