gennaro 0.3.1.1 → 0.3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gennaro/version.rb +1 -1
- data/templates/authentication/_class_name_.rb +1 -1
- data/templates/authentication/app/controllers/application.rb +1 -1
- data/templates/authentication/app/controllers/users.rb +6 -1
- data/templates/authentication/app/models/user.rb +28 -16
- data/templates/authentication/spec/spec.rb +1 -1
- data/templates/authentication/spec/user_spec.rb +8 -8
- data/templates/authentication/views/index.erb +7 -0
- data/templates/authentication/views/{user/template → template}/footer.erb +0 -0
- data/templates/authentication/views/{user/template → template}/header.erb +0 -0
- data/templates/authentication/views/user/login.erb +2 -2
- data/templates/authentication/views/user/logout.erb +2 -2
- data/templates/authentication/views/user/lost_password.erb +2 -2
- data/templates/authentication/views/user/new_password.erb +2 -2
- data/templates/authentication/views/user/password_recovery.erb +2 -2
- data/templates/authentication/views/user/signup.erb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48ecc5308d589cf1d483ebaf139439e2aa52d965
|
4
|
+
data.tar.gz: f87ae572b85862de95bf6365ac88366dfd369f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6695db947112c8a47d3ffcea8c92bbee4fb37562f437bb3c4dfacffc42968adea62c7f32d68a69005b4b2f42115ca4ffbbc3f7d4c008570a3b39b48eb4180e30
|
7
|
+
data.tar.gz: 04db7120acea41a6ae554e1a4ef9e8fcdbb26957881408719b596a0174eddfeb6cac7387a36c36794e9b05c8bdfb32d357ad022bc1f74f4519b237354c3c3132
|
data/lib/gennaro/version.rb
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
class ${ClassName}
|
12
12
|
get '/user/login/?' do
|
13
|
+
@error = 'You are already logged in.' if logged_in?
|
13
14
|
erb :'user/login'
|
14
15
|
end
|
15
16
|
|
@@ -26,14 +27,17 @@ class ${ClassName}
|
|
26
27
|
end
|
27
28
|
|
28
29
|
get '/user/signup/?' do
|
30
|
+
@error = 'You are already logged in.' if logged_in?
|
29
31
|
erb :'user/signup'
|
30
32
|
end
|
31
33
|
|
32
34
|
get '/user/lost_password/?' do
|
35
|
+
@error = 'You are already logged in.' if logged_in?
|
33
36
|
erb :'user/lost_password'
|
34
37
|
end
|
35
38
|
|
36
39
|
get '/user/password_recovery/?' do
|
40
|
+
@error = 'You are already logged in.' if logged_in?
|
37
41
|
erb :'user/password_recovery'
|
38
42
|
end
|
39
43
|
|
@@ -63,7 +67,8 @@ class ${ClassName}
|
|
63
67
|
elsif User.exists? params[:username]
|
64
68
|
@error = 'The username you have chosen is already taken.'
|
65
69
|
else
|
66
|
-
|
70
|
+
level = User.empty? ? User.founder : User.user
|
71
|
+
user = User.signup params[:username], params[:email], params[:password], level
|
67
72
|
if user.errors.any?
|
68
73
|
@error = user.errors.first
|
69
74
|
else
|
@@ -35,8 +35,12 @@ class User
|
|
35
35
|
self.salted_password = BCrypt::Engine.hash_secret password, salt
|
36
36
|
end
|
37
37
|
|
38
|
+
def banned?
|
39
|
+
self.permission_level == User.banned
|
40
|
+
end
|
41
|
+
|
38
42
|
def founder?
|
39
|
-
self.
|
43
|
+
self.permission_level == User.founder
|
40
44
|
end
|
41
45
|
|
42
46
|
def admin?
|
@@ -56,14 +60,14 @@ class User
|
|
56
60
|
self.permission_level == User.user
|
57
61
|
end
|
58
62
|
|
59
|
-
def banned?
|
60
|
-
self.permission_level == User.banned
|
61
|
-
end
|
62
|
-
|
63
63
|
def guest?
|
64
64
|
false
|
65
65
|
end
|
66
66
|
|
67
|
+
def staff?
|
68
|
+
founder? || admin? || smod? || mod?
|
69
|
+
end
|
70
|
+
|
67
71
|
def logged?(session)
|
68
72
|
self.session == session
|
69
73
|
end
|
@@ -80,33 +84,41 @@ class User
|
|
80
84
|
-1
|
81
85
|
end
|
82
86
|
|
83
|
-
def
|
87
|
+
def founder
|
84
88
|
0
|
85
89
|
end
|
86
90
|
|
87
|
-
def
|
91
|
+
def admin
|
88
92
|
1
|
89
93
|
end
|
94
|
+
|
95
|
+
def smod
|
96
|
+
2
|
97
|
+
end
|
90
98
|
alias_method :gmod, :smod
|
91
99
|
|
92
100
|
def mod
|
93
|
-
|
101
|
+
3
|
94
102
|
end
|
95
103
|
|
96
104
|
def user
|
97
|
-
|
105
|
+
4
|
98
106
|
end
|
99
107
|
|
100
108
|
def guest
|
101
|
-
|
109
|
+
5
|
110
|
+
end
|
111
|
+
|
112
|
+
def empty?
|
113
|
+
User.count == 0
|
102
114
|
end
|
103
115
|
|
104
116
|
def get(username)
|
105
|
-
User.first
|
117
|
+
User.first username: username
|
106
118
|
end
|
107
119
|
|
108
120
|
def exists?(username)
|
109
|
-
User.count(:
|
121
|
+
User.count(username: username) == 1
|
110
122
|
end
|
111
123
|
|
112
124
|
def registration(username, email, password, permission_level, stuff = {})
|
@@ -120,10 +132,10 @@ class User
|
|
120
132
|
alias_method :signup, :registration
|
121
133
|
|
122
134
|
def authentication(username, password)
|
123
|
-
user = User.first
|
135
|
+
user = User.first username: username
|
124
136
|
return false unless user
|
125
137
|
if user.salted_password == BCrypt::Engine.hash_secret(password, user.salt)
|
126
|
-
return user.update(:
|
138
|
+
return user.update(session: BCrypt::Engine.generate_salt) ? user.session : false
|
127
139
|
else
|
128
140
|
false
|
129
141
|
end
|
@@ -133,9 +145,9 @@ class User
|
|
133
145
|
alias_method :authenticate, :authentication
|
134
146
|
|
135
147
|
def lost_password(username)
|
136
|
-
user = User.first
|
148
|
+
user = User.first username: username
|
137
149
|
return false unless user
|
138
|
-
user.update
|
150
|
+
user.update lost_password: BCrypt::Engine.generate_salt
|
139
151
|
user.lost_password
|
140
152
|
end
|
141
153
|
|
@@ -4,7 +4,7 @@ require './spec'
|
|
4
4
|
require 'rspec'
|
5
5
|
require 'rack/test'
|
6
6
|
|
7
|
-
describe '
|
7
|
+
describe 'Stanco' do
|
8
8
|
def app
|
9
9
|
Sinatra::Application
|
10
10
|
end
|
@@ -13,16 +13,16 @@ describe 'App' do
|
|
13
13
|
username = 'Gennaro'
|
14
14
|
email = 'gennaro@bullo.pk'
|
15
15
|
password = 'sonopropriounbullo!'
|
16
|
-
|
16
|
+
level = User.empty? ? User.founder : User.user
|
17
17
|
|
18
18
|
User.exists?(username).should be_false
|
19
|
-
user = User.signup username, email, password,
|
20
|
-
user.errors.should
|
21
|
-
user.guest?.should
|
22
|
-
user.
|
19
|
+
user = User.signup username, email, password, level
|
20
|
+
user.errors.should be_empty
|
21
|
+
user.guest?.should be_false
|
22
|
+
user.founder?.should be_true
|
23
23
|
User.exists?(username).should be_true
|
24
24
|
|
25
|
-
user = User.signup username, email, password,
|
25
|
+
user = User.signup username, email, password, level
|
26
26
|
user.errors.should_not be_empty
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ describe 'App' do
|
|
30
30
|
username = 'Gennaro'
|
31
31
|
password = 'sonopropriounbullo!'
|
32
32
|
|
33
|
-
User.exists?(username).should
|
33
|
+
User.exists?(username).should be_true
|
34
34
|
User.login(username, password).should be_true
|
35
35
|
user = User.get username
|
36
36
|
user.session.should have(29).chars
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= erb :'
|
1
|
+
<%= erb :'template/header' %>
|
2
2
|
|
3
3
|
<% if defined? @error %>
|
4
4
|
<p class="error"><%= @error %></p>
|
@@ -6,4 +6,4 @@
|
|
6
6
|
<p class="success"><%= @success %></p>
|
7
7
|
<% end %>
|
8
8
|
|
9
|
-
<%= erb :'
|
9
|
+
<%= erb :'template/footer' %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gennaro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.1.
|
4
|
+
version: 0.3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -63,14 +63,15 @@ files:
|
|
63
63
|
- templates/authentication/Rakefile
|
64
64
|
- templates/authentication/spec/spec.rb
|
65
65
|
- templates/authentication/spec/user_spec.rb
|
66
|
+
- templates/authentication/views/index.erb
|
67
|
+
- templates/authentication/views/template/footer.erb
|
68
|
+
- templates/authentication/views/template/header.erb
|
66
69
|
- templates/authentication/views/user/login.erb
|
67
70
|
- templates/authentication/views/user/logout.erb
|
68
71
|
- templates/authentication/views/user/lost_password.erb
|
69
72
|
- templates/authentication/views/user/new_password.erb
|
70
73
|
- templates/authentication/views/user/password_recovery.erb
|
71
74
|
- templates/authentication/views/user/signup.erb
|
72
|
-
- templates/authentication/views/user/template/footer.erb
|
73
|
-
- templates/authentication/views/user/template/header.erb
|
74
75
|
- templates/authentication/_class_name_.rb
|
75
76
|
- spec/gennaro_spec.rb
|
76
77
|
- bin/gennaro
|