mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 03:00:12 +01:00
Logut user after password change, Closes #1047
This commit is contained in:
parent
6256caeb72
commit
fafbdae079
4 changed files with 43 additions and 20 deletions
|
|
@ -9,6 +9,22 @@ module LoginSystem
|
|||
def prefs
|
||||
current_user.prefs unless current_user.nil?
|
||||
end
|
||||
|
||||
# Logout the {#current_user} and redirect to login page
|
||||
#
|
||||
# @param [String] message notification to display
|
||||
def logout_user message=t('login.logged_out')
|
||||
@user.forget_me if logged_in?
|
||||
cookies.delete :auth_token
|
||||
session['user_id'] = nil
|
||||
if ( SITE_CONFIG['authentication_schemes'].include? 'cas') && session[:cas_user]
|
||||
CASClient::Frameworks::Rails::Filter.logout(self)
|
||||
else
|
||||
reset_session
|
||||
notify :notice, message
|
||||
redirect_to_login
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
@ -132,7 +148,7 @@ module LoginSystem
|
|||
def set_current_user(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
|
||||
# overwrite if you want to have special behavior in case the user is not authorized
|
||||
# to access the current operation.
|
||||
# the default action is to redirect to the login screen
|
||||
|
|
@ -192,4 +208,14 @@ module LoginSystem
|
|||
render :text => t('login.unsuccessful'), :status => 401
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Redirect the user to the login page.
|
||||
def redirect_to_login
|
||||
respond_to do |format|
|
||||
format.html { redirect_to login_path }
|
||||
format.m { redirect_to login_path(:format => 'm') }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue