monban 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -3
- data/Gemfile.lock +2 -1
- data/README.md +4 -0
- data/lib/generators/monban/templates/app/controllers/sessions_controller.rb +7 -7
- data/lib/generators/monban/templates/app/controllers/users_controller.rb +5 -7
- data/lib/monban/controller_helpers/sign_up.rb +2 -2
- data/lib/monban/controller_helpers.rb +2 -2
- data/lib/monban/version.rb +1 -1
- data/lib/monban/warden_setup.rb +1 -1
- data/monban.gemspec +1 -0
- data/spec/monban/controller_helpers_spec.rb +3 -2
- metadata +18 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
== 0.
|
1
|
+
== 0.0.4
|
2
|
+
* Cleaned up generated controllers
|
3
|
+
* Use find_by_id instead of find so invalid sessions don't cause apps to crash
|
4
|
+
* Hashes passed in are no longer mutated via delete
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
== 0.0.3
|
7
|
+
|
8
|
+
* Fixed bug where password wasn't deleted from session params which would cause lookup to fail
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Monban 門番
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/halogenandtoast/monban.png?branch=master)](https://travis-ci.org/halogenandtoast/monban)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/halogenandtoast/monban.png)](https://codeclimate.com/github/halogenandtoast/monban)
|
5
|
+
|
6
|
+
|
3
7
|
Monban is designed to be very simple and extensible user authentication. It's goal is to give all the power to the developer instead of
|
4
8
|
forcing them to make Monban work with their system
|
5
9
|
|
@@ -3,13 +3,9 @@ class SessionsController < ApplicationController
|
|
3
3
|
end
|
4
4
|
|
5
5
|
def create
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
else
|
10
|
-
flash.now.notice = "Invalid username or password"
|
11
|
-
render :new
|
12
|
-
end
|
6
|
+
user = authenticate_session(session_params)
|
7
|
+
sign_in(user) or set_flash_message
|
8
|
+
respond_with user, location: root_path
|
13
9
|
end
|
14
10
|
|
15
11
|
def destroy
|
@@ -19,6 +15,10 @@ class SessionsController < ApplicationController
|
|
19
15
|
|
20
16
|
private
|
21
17
|
|
18
|
+
def set_flash_message
|
19
|
+
flash.now.notice = "Invalid username or password"
|
20
|
+
end
|
21
|
+
|
22
22
|
def session_params
|
23
23
|
<% if config[:use_strong_parameters] -%>
|
24
24
|
params.require(:session).permit(:email, :password)
|
@@ -1,16 +1,14 @@
|
|
1
1
|
class UsersController < ApplicationController
|
2
|
+
respond_to :html
|
3
|
+
|
2
4
|
def new
|
3
5
|
@user = User.new
|
4
6
|
end
|
5
7
|
|
6
8
|
def create
|
7
|
-
user = sign_up(user_params)
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
@user = user
|
12
|
-
render :new
|
13
|
-
end
|
9
|
+
@user = sign_up(user_params)
|
10
|
+
sign_in(@user)
|
11
|
+
respond_with @user, location: root_path
|
14
12
|
end
|
15
13
|
|
16
14
|
private
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Monban
|
2
2
|
class SignUp
|
3
3
|
def initialize user_params
|
4
|
-
unencrypted_token = user_params.
|
4
|
+
unencrypted_token = user_params.slice(token_field)
|
5
5
|
token_digest = Monban.encrypt_token(unencrypted_token)
|
6
|
-
@user_params = user_params.merge(token_store_field.to_sym => token_digest)
|
6
|
+
@user_params = user_params.except(token_field).merge(token_store_field.to_sym => token_digest)
|
7
7
|
end
|
8
8
|
|
9
9
|
def perform
|
@@ -25,8 +25,8 @@ module Monban
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def authenticate_session session_params, field_map = nil
|
28
|
-
password = session_params.
|
29
|
-
user = Monban.lookup(session_params, field_map)
|
28
|
+
password = session_params.fetch(Monban.config.user_token_field)
|
29
|
+
user = Monban.lookup(session_params.except(Monban.config.user_token_field), field_map)
|
30
30
|
authenticate(user, password)
|
31
31
|
end
|
32
32
|
|
data/lib/monban/version.rb
CHANGED
data/lib/monban/warden_setup.rb
CHANGED
data/monban.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'rails'
|
21
21
|
gem.add_dependency 'bcrypt-ruby'
|
22
22
|
gem.add_dependency 'warden'
|
23
|
+
gem.add_development_dependency 'rake'
|
23
24
|
gem.add_development_dependency 'rspec'
|
24
25
|
gem.add_development_dependency 'rspec-rails'
|
25
26
|
gem.add_development_dependency 'capybara'
|
@@ -68,14 +68,15 @@ module Monban
|
|
68
68
|
user = double()
|
69
69
|
authentication = double()
|
70
70
|
authentication.should_receive(:perform).and_return(user)
|
71
|
-
Monban.should_receive(:lookup).with(session_params, field_map).and_return(user)
|
71
|
+
Monban.should_receive(:lookup).with(session_params.except('password'), field_map).and_return(user)
|
72
72
|
Authentication.should_receive(:new).with(user, 'password').and_return(authentication)
|
73
73
|
@dummy.authenticate_session(session_params, field_map).should == user
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'returns false when it could not authenticate the user' do
|
77
77
|
session_params = double()
|
78
|
-
session_params.should_receive(:
|
78
|
+
session_params.should_receive(:fetch).with('password').and_return('password')
|
79
|
+
session_params.should_receive(:except).with('password').and_return(session_params)
|
79
80
|
user = double()
|
80
81
|
authentication = double()
|
81
82
|
authentication.should_receive(:perform).and_return(false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-02-
|
13
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -60,6 +60,22 @@ dependencies:
|
|
60
60
|
- - ! '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
63
79
|
- !ruby/object:Gem::Dependency
|
64
80
|
name: rspec
|
65
81
|
requirement: !ruby/object:Gem::Requirement
|