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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fa54f044221ea0cd5dac9a02f18d8c5042b547c
4
- data.tar.gz: e1ad1f09ab1f55a14bec6e61edaf9707f718165f
3
+ metadata.gz: 48ecc5308d589cf1d483ebaf139439e2aa52d965
4
+ data.tar.gz: f87ae572b85862de95bf6365ac88366dfd369f1c
5
5
  SHA512:
6
- metadata.gz: d314b58167bd5320fbfb5e46241bd5e547f07d08b44620c79f3417e29f4e45091896d3a1c3e6a99e2ed02f7ac8bfe4c9649c271432eaf21dab425ebf98874514
7
- data.tar.gz: 0e987c997b3784438203c5a983b2dce4d6b06bdd3fbd16bd79bc995cc53974054134e9747d2bbd9f9ed5076a0053685b99eb5d52b6352a9bb945d9a4e97594e4
6
+ metadata.gz: 6695db947112c8a47d3ffcea8c92bbee4fb37562f437bb3c4dfacffc42968adea62c7f32d68a69005b4b2f42115ca4ffbbc3f7d4c008570a3b39b48eb4180e30
7
+ data.tar.gz: 04db7120acea41a6ae554e1a4ef9e8fcdbb26957881408719b596a0174eddfeb6cac7387a36c36794e9b05c8bdfb32d357ad022bc1f74f4519b237354c3c3132
@@ -10,6 +10,6 @@
10
10
 
11
11
  class Gennaro
12
12
  def self.version
13
- '0.3.1.1'
13
+ '0.3.1.2'
14
14
  end
15
15
  end
@@ -34,5 +34,5 @@ class ${ClassName} < Sinatra::Base
34
34
  Dir.glob("#{Dir.pwd}/app/controllers/*.rb") { |c| require c.chomp }
35
35
 
36
36
  DataMapper.finalize
37
- User.auto_migrate!
37
+ DataMapper.auto_upgrade!
38
38
  end
@@ -17,6 +17,6 @@ class ${ClassName}
17
17
  end
18
18
 
19
19
  get '/' do
20
- 'Hello, world!'
20
+ erb :index
21
21
  end
22
22
  end
@@ -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
- user = User.signup params[:username], params[:email], params[:password], User.user
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.id == 1
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 admin
87
+ def founder
84
88
  0
85
89
  end
86
90
 
87
- def smod
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
- 2
101
+ 3
94
102
  end
95
103
 
96
104
  def user
97
- 3
105
+ 4
98
106
  end
99
107
 
100
108
  def guest
101
- 4
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(:username => username)
117
+ User.first username: username
106
118
  end
107
119
 
108
120
  def exists?(username)
109
- User.count(:username => username) == 1
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(:username => username)
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(:session => BCrypt::Engine.generate_salt) ? user.session : false
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(:username => username)
148
+ user = User.first username: username
137
149
  return false unless user
138
- user.update(:lost_password => BCrypt::Engine.generate_salt)
150
+ user.update lost_password: BCrypt::Engine.generate_salt
139
151
  user.lost_password
140
152
  end
141
153
 
@@ -34,5 +34,5 @@ class ${ClassName} < Sinatra::Base
34
34
  Dir.glob('../app/controllers/*.rb') { |c| require c.chomp }
35
35
 
36
36
  DataMapper.finalize
37
- User.auto_migrate!
37
+ DataMapper.auto_upgrade!
38
38
  end
@@ -4,7 +4,7 @@ require './spec'
4
4
  require 'rspec'
5
5
  require 'rack/test'
6
6
 
7
- describe 'App' do
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
- permission_level = User.user
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, permission_level
20
- user.errors.should be_empty
21
- user.guest?.should be_false
22
- user.user?.should be_true
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, permission_level
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 be_true
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
@@ -0,0 +1,7 @@
1
+ <%= erb :'template/header' %>
2
+ -- User --<br>
3
+ <a href="user/signup">Signup</a><br>
4
+ <a href="user/login">Login</a><br>
5
+ <a href="user/logout">Logout</a><br>
6
+ <a href="user/lost_password">Lost password</a>
7
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
1
+ <%= erb :'template/header' %>
2
2
 
3
3
  <% if defined? @error %>
4
4
  <p class="error"><%= @error %></p>
@@ -13,4 +13,4 @@
13
13
  </form>
14
14
  <% end %>
15
15
 
16
- <%= erb :'user/template/footer' %>
16
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
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 :'user/template/footer' %>
9
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
1
+ <%= erb :'template/header' %>
2
2
 
3
3
  <% if defined? @error %>
4
4
  <p class="error"><%= @error %></p>
@@ -12,4 +12,4 @@
12
12
  </form>
13
13
  <% end %>
14
14
 
15
- <%= erb :'user/template/footer' %>
15
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
1
+ <%= erb :'template/header' %>
2
2
 
3
3
  <% if defined? @error %>
4
4
  <p class="error"><%= @error %></p>
@@ -13,4 +13,4 @@
13
13
  </form>
14
14
  <% end %>
15
15
 
16
- <%= erb :'user/template/footer' %>
16
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
1
+ <%= erb :'template/header' %>
2
2
 
3
3
  <% if defined? @error %>
4
4
  <p class="error"><%= @error %></p>
@@ -14,4 +14,4 @@
14
14
  </form>
15
15
  <% end %>
16
16
 
17
- <%= erb :'user/template/footer' %>
17
+ <%= erb :'template/footer' %>
@@ -1,4 +1,4 @@
1
- <%= erb :'user/template/header' %>
1
+ <%= erb :'template/header' %>
2
2
 
3
3
  <% if defined? @error %>
4
4
  <p class="error"><%= @error %></p>
@@ -14,4 +14,4 @@
14
14
  </form>
15
15
  <% end %>
16
16
 
17
- <%= erb :'user/template/footer' %>
17
+ <%= 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.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-16 00:00:00.000000000 Z
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