Show More
Commit Description:
update mail functionality. Update syntax for mail gem (we might need more options for mail setting?)
Commit Description:
update mail functionality. Update syntax for mail gem (we might need more options for mail setting?)
File last commit:
Show/Diff file:
Action:
app/controllers/users_controller.rb | 156 lines | 4.9 KiB | text/x-ruby | RubyLexer |
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 require 'net/smtp'
jittat
more work on registration...
r157
pramook
initial commit...
r0 class UsersController < ApplicationController
jittat
added user settings...
r13
Jittat Fakcharoenphol
moved send mail code back to helper
r336 include MailHelperMethods
jittat
added password recovery through e-mails...
r189 before_filter :authenticate, :except => [:new,
:register,
:confirm,
:forget,
:retrieve_password]
jittat
added user settings...
r13
jittat
added password recovery through e-mails...
r189 before_filter :verify_online_registration, :only => [:new,
:register,
:forget,
:retrieve_password]
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162
jittat
added user settings...
r13 verify :method => :post, :only => [:chg_passwd],
:redirect_to => { :action => :index }
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 #in_place_edit_for :user, :alias_for_editing
#in_place_edit_for :user, :email_for_editing
jittat
added user settings...
r13
def index
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if !GraderConfiguration['system.user_setting_enabled']
jittat
added 'user_setting_enabled' option...
r156 redirect_to :controller => 'main', :action => 'list'
else
@user = User.find(session[:user_id])
end
jittat
added user settings...
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
jittat
more work on registration...
r157 def new
@user = User.new
render :action => 'new', :layout => 'empty'
end
def register
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 if(params[:cancel])
redirect_to :controller => 'main', :action => 'login'
return
end
jittat
more work on registration...
r157 @user = User.new(params[:user])
@user.password_confirmation = @user.password = User.random_password
@user.activated = false
if (@user.valid?) and (@user.save)
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 if send_confirmation_email(@user)
render :action => 'new_splash', :layout => 'empty'
else
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 @admin_email = GraderConfiguration['system.admin_email']
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 render :action => 'email_error', :layout => 'empty'
end
jittat
more work on registration...
r157 else
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 @user.errors.add(:base,"Email cannot be blank") if @user.email==''
jittat
more work on registration...
r157 render :action => 'new', :layout => 'empty'
end
end
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 def confirm
login = params[:login]
key = params[:activation]
jittat
fixed user confirmation bug...
r160 @user = User.find_by_login(login)
if (@user) and (@user.verify_activation_key(key))
if @user.valid? # check uniquenss of email
@user.activated = true
@user.save
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 @result = :successful
else
@result = :email_used
end
else
@result = :failed
end
render :action => 'confirm', :layout => 'empty'
end
jittat
added password recovery through e-mails...
r189 def forget
render :action => 'forget', :layout => 'empty'
end
def retrieve_password
email = params[:email]
user = User.find_by_email(email)
if user
last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour)
if last_updated_time > Time.now.gmtime - 5.minutes
flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes'
else
user.password = user.password_confirmation = User.random_password
jittat
MERGED bug fix on user password recovery from ytopc branch (change set 402:403)...
r191 user.save
jittat
added password recovery through e-mails...
r189 send_new_password_email(user)
flash[:notice] = 'New password has been mailed to you.'
end
else
flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
end
redirect_to :action => 'forget'
end
jittat
more work on registration...
r157 protected
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 def verify_online_registration
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if !GraderConfiguration['system.online_registration']
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 redirect_to :controller => 'main', :action => 'login'
end
end
jittat
more work on registration...
r157 def send_confirmation_email(user)
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 contest_name = GraderConfiguration['contest.name']
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 activation_url = url_for(:action => 'confirm',
:login => user.login,
:activation => user.activation_key)
home_url = url_for(:controller => 'main', :action => 'index')
Jittat Fakcharoenphol
sends mails by mail gem
r331 mail_subject = "[#{contest_name}] Confirmation"
mail_body = t('registration.email_body', {
:full_name => user.full_name,
:contest_name => contest_name,
:login => user.login,
:password => user.password,
:activation_url => activation_url,
update mail functionality. Update syntax for mail gem (we might need more options for mail setting?)
r348 :admin_email => GraderConfiguration['system.admin_email']
Jittat Fakcharoenphol
sends mails by mail gem
r331 })
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158
Jittat Fakcharoenphol
sends mails by mail gem
r331 logger.info mail_body
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158
Jittat Fakcharoenphol
moved send mail code back to helper
r336 send_mail(user.email, mail_subject, mail_body)
jittat
more work on registration...
r157 end
jittat
added password recovery through e-mails...
r189 def send_new_password_email(user)
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 contest_name = GraderConfiguration['contest.name']
Jittat Fakcharoenphol
sends mails by mail gem
r331 mail_subject = "[#{contest_name}] Password recovery"
mail_body = t('registration.password_retrieval.email_body', {
:full_name => user.full_name,
:contest_name => contest_name,
:login => user.login,
:password => user.password,
update mail functionality. Update syntax for mail gem (we might need more options for mail setting?)
r348 :admin_email => GraderConfiguration['system.admin_email']
Jittat Fakcharoenphol
sends mails by mail gem
r331 })
jittat
added password recovery through e-mails...
r189
Jittat Fakcharoenphol
sends mails by mail gem
r331 logger.info mail_body
Jittat Fakcharoenphol
moved send mail code back to helper
r336 send_mail(user.email, mail_subject, mail_body)
jittat
added password recovery through e-mails...
r189 end
pramook
initial commit...
r0 end