Class: Blogaze::Controllers::Users
- Inherits:
-
Controller
- Object
- Ramaze::Controller
- Controller
- Blogaze::Controllers::Users
- Defined in:
- lib/blogaze/controllers/users.rb
Instance Method Summary collapse
-
#create ⇒ Object
Create user.
-
#new ⇒ Object
Register form.
-
#profile ⇒ Object
“UserCP”.
-
#save ⇒ Object
Save profile.
Methods inherited from Controller
#get_settings, #initialize, #title, #view_file
Constructor Details
This class inherits a constructor from Blogaze::Controllers::Controller
Instance Method Details
#create ⇒ Object
Create user
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/blogaze/controllers/users.rb', line 26 def create return redirect('/') unless request.post? title "Register" data = { :username => request[:username], :password => request[:password], :email => request[:email], :group_id => 3 } @user = ::Blogaze::Models::User.new(data) # Check for errors if @user.valid? @user.save flash[:success] = "Account created, you may now login" redirect '/login' else respond(view_file('users/new')) end end |
#new ⇒ Object
Register form
17 18 19 20 21 |
# File 'lib/blogaze/controllers/users.rb', line 17 def new title "Register" @user = ::Blogaze::Models::User.new respond(view_file('users/new')) end |
#profile ⇒ Object
“UserCP”
52 53 54 55 56 |
# File 'lib/blogaze/controllers/users.rb', line 52 def profile return respond(view_file('sessions/new')) unless session[:logged_in] title "Profile" respond(view_file('users/profile')) end |
#save ⇒ Object
Save profile
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/blogaze/controllers/users.rb', line 61 def save return redirect('/') unless request.post? # Set title title "Profile" # Set email @userinfo.email = request[:email] # Changing password? if not request[:new_password].empty? @userinfo.change_password(request[:new_password]) end # Check for errors if @userinfo.valid? @userinfo.save redirect Users.r('/profile') else respond(view_file('users/profile')) end end |