honey-auth 0.1.0 → 0.2.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 +15 -0
- data/lib/generators/honey_auth/init_generator.rb +14 -3
- data/{app/controllers → lib/generators/honey_auth/templates}/accounts_controller.rb +11 -5
- data/{app/controllers → lib/generators/honey_auth/templates}/sessions_controller.rb +2 -2
- data/lib/generators/honey_auth/templates/user_model.rb +2 -2
- data/{app/views/accounts/edit.html.haml → lib/generators/honey_auth/templates/views/accounts/edit.html.slim} +2 -2
- data/{app/views/accounts/new.html.haml → lib/generators/honey_auth/templates/views/accounts/new.html.slim} +3 -3
- data/{app/views/sessions/new.html.haml → lib/generators/honey_auth/templates/views/sessions/new.html.slim} +2 -2
- data/lib/honey_auth/engine.rb +2 -0
- data/lib/honey_auth/roles.rb +13 -1
- metadata +24 -19
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ZDNlNTg4ODU3OTMzNTEzOGExM2U2OGU0ZmFhM2Q0NzkxOGJlNjI2OQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
YjQ0M2RlMWNhZDU4MjY4MWIxYzdhNmVkZjBhNTEyODY0NzQ0MzJmZA==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MDFmYTBjY2QzZGJkZTg5NGM3ZjQ4MDliNWVlNGY5ZjRlMTNlODdhNWFmNWMy
|
|
10
|
+
NmUzMDJhOGMyYzc2ZDQ0YmM5NmZmOGE1ZjA4YTJiMmY4OTk4MTQwNDQ3MWVk
|
|
11
|
+
NjhjY2MyYzY1MjdiMjZlN2FkYWU3Mzk2NjJmZTU4NmNlY2UyYTE=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YWRjNmI4MmVmNjBjZGFjM2Y4YmY0MmM0NGM3ODYwYWUxODBjZmU4YTEwNGU5
|
|
14
|
+
ZmE0OTA2OTQxYTVkNjc1ZGYxMTQxMGZjNWZiM2Y5OTk1ZmY5YjFiNWFiMjkw
|
|
15
|
+
OGIzNzhjNjVhN2MzNmJkZWRlZjk5ZTZhYTYyNjZmYzJmNjVmNDM=
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'rails/generators/active_record
|
|
1
|
+
require 'rails/generators/active_record'
|
|
2
2
|
require 'generators/honey_auth/base'
|
|
3
3
|
|
|
4
4
|
module HoneyAuth
|
|
@@ -6,12 +6,23 @@ module HoneyAuth
|
|
|
6
6
|
|
|
7
7
|
class Init < Base
|
|
8
8
|
include Rails::Generators::Migration
|
|
9
|
-
extend ActiveRecord::Generators::Migration
|
|
10
9
|
source_root File.expand_path('../templates', __FILE__)
|
|
11
10
|
|
|
12
11
|
def create_migration_file
|
|
13
|
-
template 'user_model.rb', 'app/models/user.rb'
|
|
14
12
|
migration_template 'user_migration.rb', 'db/migrate/create_users'
|
|
13
|
+
template 'user_model.rb', 'app/models/user.rb'
|
|
14
|
+
template 'accounts_controller.rb', 'app/controllers/accounts_controller.rb'
|
|
15
|
+
template 'sessions_controller.rb', 'app/controllers/sessions_controller.rb'
|
|
16
|
+
directory 'views/sessions', 'app/views/sessions'
|
|
17
|
+
directory 'views/accounts', 'app/views/accounts'
|
|
18
|
+
|
|
19
|
+
inject_into_file 'app/controllers/application_controller.rb', before: 'end' do
|
|
20
|
+
' include Authentication' << "\n"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.next_migration_number(dirname)
|
|
25
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
15
26
|
end
|
|
16
27
|
end
|
|
17
28
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
class AccountsController < ApplicationController
|
|
2
|
-
before_filter :signed_in
|
|
2
|
+
before_filter :signed_in!, only: [:edit, :update]
|
|
3
3
|
|
|
4
4
|
def new
|
|
5
5
|
@user = User.new
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def create
|
|
9
|
-
@user = User.new(
|
|
9
|
+
@user = User.new(user_params)
|
|
10
10
|
|
|
11
11
|
if @user.save
|
|
12
12
|
sign_in @user
|
|
@@ -17,12 +17,12 @@ class AccountsController < ApplicationController
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def update
|
|
20
|
-
|
|
20
|
+
user_params.delete(:password) unless user_params[:password].present?
|
|
21
21
|
@user = current_user
|
|
22
|
-
@user.attributes =
|
|
22
|
+
@user.attributes = user_params
|
|
23
23
|
|
|
24
24
|
if @user.save
|
|
25
|
-
redirect_to
|
|
25
|
+
redirect_to root_path
|
|
26
26
|
else
|
|
27
27
|
render 'accounts/edit'
|
|
28
28
|
end
|
|
@@ -31,4 +31,10 @@ class AccountsController < ApplicationController
|
|
|
31
31
|
def edit
|
|
32
32
|
@user = current_user
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
protected
|
|
36
|
+
|
|
37
|
+
def user_params
|
|
38
|
+
params.require(:user).permit(:classcode, :email, :name, :username, :password, :password_confirmation)
|
|
39
|
+
end
|
|
34
40
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class SessionsController < ApplicationController
|
|
2
|
-
before_filter :signed_in
|
|
2
|
+
before_filter :signed_in!, only: [:destroy]
|
|
3
3
|
|
|
4
4
|
def create
|
|
5
5
|
if @user = User.find_by_email(params[:user][:email]).try(:authenticate, params[:user][:password])
|
|
@@ -7,7 +7,7 @@ class SessionsController < ApplicationController
|
|
|
7
7
|
redirect_to signed_in_path(:signed_in)
|
|
8
8
|
else
|
|
9
9
|
@user = User.new
|
|
10
|
-
flash[:error] = '
|
|
10
|
+
flash[:error] = 'Incorrect email or password'
|
|
11
11
|
render :new
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class User < ActiveRecord::Base
|
|
2
2
|
has_secure_password
|
|
3
|
-
attr_accessible :email, :name, :password, :password_confirmation
|
|
4
3
|
validates :email, presence: true
|
|
5
4
|
validates_uniqueness_of :email, case_sensitive: false, allow_nil: true
|
|
6
|
-
ROLES
|
|
5
|
+
ROLES = %w(user admin)
|
|
6
|
+
SAFE_ROLES = %w(user)
|
|
7
7
|
include HoneyAuth::Roles
|
|
8
8
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
article.new-account-page
|
|
2
|
+
h3 Sign up for an account
|
|
3
3
|
|
|
4
4
|
= form_for @user, url: account_path do |f|
|
|
5
5
|
= f.string :name
|
|
6
6
|
= f.email :email
|
|
7
7
|
= f.password :password
|
|
8
8
|
= f.password :password_confirmation
|
|
9
|
-
= f.actions save: '
|
|
9
|
+
= f.actions save: 'Sign up'
|
data/lib/honey_auth/engine.rb
CHANGED
data/lib/honey_auth/roles.rb
CHANGED
|
@@ -5,6 +5,18 @@ module HoneyAuth::Roles
|
|
|
5
5
|
|
|
6
6
|
def role= role
|
|
7
7
|
remove_instance_variable :@role_inquirer if defined?(@role_inquirer)
|
|
8
|
-
|
|
8
|
+
safe_role_assignment role
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def safe_role_assignment role
|
|
12
|
+
self[:role] = if sanitized_role = SAFE_ROLES.find{ |r| r == role.strip }
|
|
13
|
+
sanitized_role
|
|
14
|
+
else
|
|
15
|
+
'user'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def assign_reserved_role role
|
|
20
|
+
self[:role] = role
|
|
9
21
|
end
|
|
10
22
|
end
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: honey-auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.2.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Quinn Shanahan
|
|
@@ -13,26 +12,32 @@ date: 2012-10-16 00:00:00.000000000 Z
|
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: haml
|
|
16
|
-
requirement:
|
|
17
|
-
none: false
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
16
|
requirements:
|
|
19
17
|
- - ! '>='
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '0'
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: bcrypt-ruby
|
|
27
|
-
requirement: &70154157659900 !ruby/object:Gem::Requirement
|
|
28
|
-
none: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
29
23
|
requirements:
|
|
30
24
|
- - ! '>='
|
|
31
25
|
- !ruby/object:Gem::Version
|
|
32
26
|
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bcrypt-ruby
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 3.0.0
|
|
33
34
|
type: :runtime
|
|
34
35
|
prerelease: false
|
|
35
|
-
version_requirements:
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 3.0.0
|
|
36
41
|
description: Very basic auth generator
|
|
37
42
|
email: q.shanahan@gmail.com
|
|
38
43
|
executables: []
|
|
@@ -42,40 +47,40 @@ files:
|
|
|
42
47
|
- lib/authentication.rb
|
|
43
48
|
- lib/generators/honey_auth/base.rb
|
|
44
49
|
- lib/generators/honey_auth/init_generator.rb
|
|
50
|
+
- lib/generators/honey_auth/templates/accounts_controller.rb
|
|
51
|
+
- lib/generators/honey_auth/templates/sessions_controller.rb
|
|
45
52
|
- lib/generators/honey_auth/templates/user_migration.rb
|
|
46
53
|
- lib/generators/honey_auth/templates/user_model.rb
|
|
54
|
+
- lib/generators/honey_auth/templates/views/accounts/edit.html.slim
|
|
55
|
+
- lib/generators/honey_auth/templates/views/accounts/new.html.slim
|
|
56
|
+
- lib/generators/honey_auth/templates/views/sessions/new.html.slim
|
|
47
57
|
- lib/honey-auth.rb
|
|
48
58
|
- lib/honey_auth/engine.rb
|
|
49
59
|
- lib/honey_auth/roles.rb
|
|
50
60
|
- lib/honey_auth/routes.rb
|
|
51
61
|
- lib/honey_auth.rb
|
|
52
|
-
- app/controllers/accounts_controller.rb
|
|
53
|
-
- app/controllers/sessions_controller.rb
|
|
54
|
-
- app/views/accounts/edit.html.haml
|
|
55
|
-
- app/views/accounts/new.html.haml
|
|
56
|
-
- app/views/sessions/new.html.haml
|
|
57
62
|
homepage: https://github.com/honeyco/honey-auth
|
|
58
63
|
licenses: []
|
|
64
|
+
metadata: {}
|
|
59
65
|
post_install_message:
|
|
60
66
|
rdoc_options: []
|
|
61
67
|
require_paths:
|
|
62
68
|
- lib
|
|
63
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
-
none: false
|
|
65
70
|
requirements:
|
|
66
71
|
- - ! '>='
|
|
67
72
|
- !ruby/object:Gem::Version
|
|
68
73
|
version: '0'
|
|
69
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
-
none: false
|
|
71
75
|
requirements:
|
|
72
76
|
- - ! '>='
|
|
73
77
|
- !ruby/object:Gem::Version
|
|
74
78
|
version: '0'
|
|
75
79
|
requirements: []
|
|
76
80
|
rubyforge_project:
|
|
77
|
-
rubygems_version:
|
|
81
|
+
rubygems_version: 2.0.7
|
|
78
82
|
signing_key:
|
|
79
|
-
specification_version:
|
|
83
|
+
specification_version: 4
|
|
80
84
|
summary: Auth
|
|
81
85
|
test_files: []
|
|
86
|
+
has_rdoc:
|