app/controllers/admin/sessions_controller.rb in camaleon_cms-0.2.1 vs app/controllers/admin/sessions_controller.rb in camaleon_cms-1.0
- old
+ new
@@ -28,11 +28,11 @@
@user = current_site.users.find_by_username(data_user[:username])
captcha_validate = captcha_verify_if_under_attack("login")
r = {user: @user, params: params, password: data_user[:password], captcha_validate: captcha_validate}; hooks_run("user_before_login", r)
if captcha_validate && @user && @user.authenticate(data_user[:password])
captcha_reset_attack("login")
- login_user(@user)
+ login_user(@user, params[:remember_me].present?)
else
captcha_increment_attack("login")
if captcha_validate
flash[:error] = t('admin.login.message.fail')
else
@@ -76,10 +76,11 @@
render "forgot"
return
end
end
+ # TODO: Move this out of the controller
# send email reset password
if params[:user].present?
data_user = params[:user]
@user = current_site.users.find_by_email(data_user[:email])
if @user.present?
@@ -88,21 +89,20 @@
reset_url = admin_forgot_url({h: @user.password_reset_token})
html = "<p>#{t('admin.login.message.hello')}, <b>#{@user.fullname}</b></p>
<p>#{t('admin.login.message.reset_url')}:</p>
<p><a href='#{reset_url}'><b>#{reset_url}</b></a></p> "
- sendmail(@user.email,t('admin.login.message.subject_email'),html)
+ sendmail(@user.email,t('admin.login.message.subject_email'), html)
flash[:notice] = t('admin.login.message.send_mail_succes')
redirect_to admin_login_path
return
else
flash[:error] = t('admin.login.message.send_mail_error')
@user = current_site.users.new(data_user)
end
end
-
end
def register
@user ||= current_site.users.new
@@ -126,19 +126,18 @@
render "register"
end
else
render "register"
end
-
- return
end
private
+
def before_hook_session
I18n.locale = params[:locale] || current_site.get_languages.first
hooks_run("session_before_load")
- end
+ end
+
def after_hook_session
hooks_run("session_after_load")
end
-
end