blogaze 0.0.3 → 0.1.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.
|
@@ -11,13 +11,21 @@ module Blogaze
|
|
|
11
11
|
class Users < Controller
|
|
12
12
|
map '/users'
|
|
13
13
|
|
|
14
|
+
##
|
|
15
|
+
# Register form
|
|
16
|
+
#
|
|
14
17
|
def new
|
|
15
18
|
@title = "Register - #{@settings[:title]}"
|
|
16
19
|
@user = ::Blogaze::Models::User.new
|
|
17
20
|
respond(view_file('users/new'))
|
|
18
21
|
end
|
|
19
22
|
|
|
23
|
+
##
|
|
24
|
+
# Create user
|
|
25
|
+
#
|
|
20
26
|
def create
|
|
27
|
+
return redirect('/') unless request.post?
|
|
28
|
+
|
|
21
29
|
@title = "Register - #{@settings[:title]}"
|
|
22
30
|
data = {
|
|
23
31
|
:username => request[:username],
|
|
@@ -28,6 +36,7 @@ module Blogaze
|
|
|
28
36
|
|
|
29
37
|
@user = ::Blogaze::Models::User.new(data)
|
|
30
38
|
|
|
39
|
+
# Check for errors
|
|
31
40
|
if @user.valid?
|
|
32
41
|
@user.save
|
|
33
42
|
flash[:success] = "Account created, you may now login"
|
|
@@ -36,6 +45,37 @@ module Blogaze
|
|
|
36
45
|
respond(view_file('users/new'))
|
|
37
46
|
end
|
|
38
47
|
end
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# "UserCP"
|
|
51
|
+
#
|
|
52
|
+
def profile
|
|
53
|
+
return respond(view_file('sessions/new')) unless session[:logged_in]
|
|
54
|
+
respond(view_file('users/profile'))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
##
|
|
58
|
+
# Save profile
|
|
59
|
+
#
|
|
60
|
+
def save
|
|
61
|
+
return redirect('/') unless request.post?
|
|
62
|
+
|
|
63
|
+
# Set email
|
|
64
|
+
@userinfo.email = request[:email]
|
|
65
|
+
|
|
66
|
+
# Changing password?
|
|
67
|
+
if not request[:new_password].empty?
|
|
68
|
+
@userinfo.change_password(request[:new_password])
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Check for errors
|
|
72
|
+
if @userinfo.valid?
|
|
73
|
+
@userinfo.save
|
|
74
|
+
redirect Users.r('/profile')
|
|
75
|
+
else
|
|
76
|
+
respond(view_file('users/profile'))
|
|
77
|
+
end
|
|
78
|
+
end
|
|
39
79
|
end # Users
|
|
40
80
|
end # Controllers
|
|
41
81
|
end # Blogaze
|
data/lib/blogaze/models/user.rb
CHANGED
|
@@ -22,6 +22,13 @@ module Blogaze
|
|
|
22
22
|
BCrypt::Password.new(self.password) == password
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
##
|
|
26
|
+
# Changes the users password.
|
|
27
|
+
#
|
|
28
|
+
def change_password(new_password)
|
|
29
|
+
self.password = BCrypt::Password.create(new_password)
|
|
30
|
+
end
|
|
31
|
+
|
|
25
32
|
def validate
|
|
26
33
|
super
|
|
27
34
|
|
data/lib/blogaze/routes.rb
CHANGED
|
@@ -23,6 +23,7 @@ module Blogaze
|
|
|
23
23
|
::Ramaze::Route['/logout'] = '/sessions/destroy'
|
|
24
24
|
::Ramaze::Route['/register'] = '/users/new'
|
|
25
25
|
::Ramaze::Route['/users/create'] = '/users/create'
|
|
26
|
+
::Ramaze::Route['/profile'] = '/users/profile'
|
|
26
27
|
::Ramaze::Route[/\/sessions(.*)/] = '/sessions%s'
|
|
27
28
|
|
|
28
29
|
# Page routes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<div id="page_content">
|
|
2
|
+
<h2 id="page-title">My Profile</h2>
|
|
3
|
+
<div class="content">
|
|
4
|
+
<?r if @userinfo.errors.count > 0 ?>
|
|
5
|
+
<div class="message error">
|
|
6
|
+
<?r @userinfo.errors.each do |k, v| ?>
|
|
7
|
+
#{k} #{v.first}<br />
|
|
8
|
+
<?r end ?>
|
|
9
|
+
</div>
|
|
10
|
+
<?r end ?>
|
|
11
|
+
<div class="profile-form tabular">
|
|
12
|
+
#{
|
|
13
|
+
form_for(@userinfo, :method => :post, :action => '/users/save') do |f|
|
|
14
|
+
f.input_text 'Email', :email
|
|
15
|
+
f.input_password 'New Password', :new_password
|
|
16
|
+
f.submit "Save", :class => "submit-btn"
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
data/lib/blogaze/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blogaze
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-01-
|
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: ramaze
|
|
@@ -175,6 +175,7 @@ files:
|
|
|
175
175
|
- lib/blogaze/themes/default/posts/view.xhtml
|
|
176
176
|
- lib/blogaze/themes/default/sessions/new.xhtml
|
|
177
177
|
- lib/blogaze/themes/default/users/new.xhtml
|
|
178
|
+
- lib/blogaze/themes/default/users/profile.xhtml
|
|
178
179
|
- lib/blogaze/version.rb
|
|
179
180
|
- proto/Rakefile
|
|
180
181
|
- proto/app.rb
|