|
|
|
@ -27,7 +27,7 @@ class AccountController < ApplicationController
|
|
|
|
|
if request.get?
|
|
|
|
|
@login = params[:login] || true
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
redirect_to home_url
|
|
|
|
|
redirect_to user_path(User.current)
|
|
|
|
|
else
|
|
|
|
|
render :layout => 'login'
|
|
|
|
|
end
|
|
|
|
@ -58,7 +58,7 @@ class AccountController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# Lets user choose a new password
|
|
|
|
|
def lost_password
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.lost_password?
|
|
|
|
|
(redirect_to(signin_path); return) unless Setting.lost_password?
|
|
|
|
|
if params[:token]
|
|
|
|
|
@token = Token.find_token("recovery", params[:token].to_s)
|
|
|
|
|
if @token.nil? || @token.expired?
|
|
|
|
@ -110,7 +110,7 @@ class AccountController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# User self-registration
|
|
|
|
|
def register
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
|
|
|
|
(redirect_to(signin_path); return) unless Setting.self_registration? || session[:auth_source_registration]
|
|
|
|
|
if request.get?
|
|
|
|
|
session[:auth_source_registration] = nil
|
|
|
|
|
@user = User.new(:language => current_language.to_s)
|
|
|
|
@ -187,11 +187,11 @@ class AccountController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# Token based account activation
|
|
|
|
|
def activate
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?
|
|
|
|
|
(redirect_to(signin_path); return) unless Setting.self_registration? && params[:token].present?
|
|
|
|
|
token = Token.find_token('register', params[:token].to_s)
|
|
|
|
|
(redirect_to(home_url); return) unless token and !token.expired?
|
|
|
|
|
(redirect_to(signin_path); return) unless token and !token.expired?
|
|
|
|
|
user = token.user
|
|
|
|
|
(redirect_to(home_url); return) unless user.registered?
|
|
|
|
|
(redirect_to(signin_path); return) unless user.registered?
|
|
|
|
|
user.activate
|
|
|
|
|
if user.save
|
|
|
|
|
token.destroy
|
|
|
|
@ -278,7 +278,7 @@ class AccountController < ApplicationController
|
|
|
|
|
user = User.find_or_initialize_by_identity_url(identity_url)
|
|
|
|
|
if user.new_record?
|
|
|
|
|
# Self-registration off
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.self_registration?
|
|
|
|
|
(redirect_to(signin_path); return) unless Setting.self_registration?
|
|
|
|
|
|
|
|
|
|
# Create on the fly
|
|
|
|
|
user.login = registration['nickname'] unless registration['nickname'].nil?
|
|
|
|
|