Show More
Commit Description:
more work on registration...
Commit Description:
more work on registration
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@296 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/controllers/users_controller.rb
| 56 lines
| 1.4 KiB
| text/x-ruby
| RubyLexer
|
|
r157 | require 'pony' | ||
|
r0 | class UsersController < ApplicationController | ||
|
r13 | |||
|
r156 | before_filter :authenticate, :except => [:new, :register] | ||
|
r13 | |||
verify :method => :post, :only => [:chg_passwd], | ||||
:redirect_to => { :action => :index } | ||||
|
r18 | in_place_edit_for :user, :alias_for_editing | ||
in_place_edit_for :user, :email_for_editing | ||||
|
r13 | |||
def index | ||||
|
r156 | if !Configuration['system.user_setting_enabled'] | ||
redirect_to :controller => 'main', :action => 'list' | ||||
else | ||||
@user = User.find(session[:user_id]) | ||||
end | ||||
|
r13 | end | ||
def chg_passwd | ||||
user = User.find(session[:user_id]) | ||||
user.password = params[:passwd] | ||||
user.password_confirmation = params[:passwd_verify] | ||||
if user.save | ||||
flash[:notice] = 'password changed' | ||||
else | ||||
flash[:notice] = 'Error: password changing failed' | ||||
end | ||||
redirect_to :action => 'index' | ||||
end | ||||
|
r157 | def new | ||
@user = User.new | ||||
render :action => 'new', :layout => 'empty' | ||||
end | ||||
def register | ||||
@user = User.new(params[:user]) | ||||
@user.password_confirmation = @user.password = User.random_password | ||||
@user.activated = false | ||||
if (@user.valid?) and (@user.save) | ||||
send_confirmation_email(@user) | ||||
render :action => 'new_splash', :layout => 'empty' | ||||
else | ||||
@user.errors.add_to_base("Email cannot be blank") if @user.email=='' | ||||
render :action => 'new', :layout => 'empty' | ||||
end | ||||
end | ||||
protected | ||||
def send_confirmation_email(user) | ||||
end | ||||
|
r0 | end | ||