Class: SessionController

Inherits:
ApplicationController show all
Defined in:
frontend/app/controllers/session_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#archivesspace, can_access?, permission_mappings, set_access_control

Instance Method Details

#become_userObject



29
30
31
32
33
34
35
36
37
# File 'frontend/app/controllers/session_controller.rb', line 29

def become_user
  if User.become_user(self, params[:username])
    flash[:success] = t("become-user.success")
    redirect_to :controller => :welcome, :action => :index
  else
    flash[:error] = t("become-user.failed")
    redirect_to :controller => :session, :action => :select_user
  end
end

#check_sessionObject

let a trusted app (i.e., public catalog) know if a user should see links back to this editing interface



48
49
50
51
52
53
54
55
56
57
# File 'frontend/app/controllers/session_controller.rb', line 48

def check_session
  response.headers['Access-Control-Allow-Origin'] = AppConfig[:public_proxy_url]
  response.headers['Access-Control-Allow-Credentials'] = 'true'

  if session[:session] && params[:uri]
    render json: user_can_edit?(params)
  else
    render json: false
  end
end

#has_sessionObject



60
61
62
# File 'frontend/app/controllers/session_controller.rb', line 60

def has_session
  render :json => {:has_session => !session[:user].nil?}
end

#loginObject



7
8
9
10
11
12
13
14
15
16
17
# File 'frontend/app/controllers/session_controller.rb', line 7

def 
  backend_session = User.(params[:username], params[:password])

  if backend_session
    User.establish_session(self, backend_session, params[:username])
  end

  load_repository_list

  render :json => {:session => backend_session, :csrf_token => form_authenticity_token}
end

#login_inlineObject



20
21
22
# File 'frontend/app/controllers/session_controller.rb', line 20

def 
  render_aspace_partial :partial => "shared/modal", :locals => {:title => t("session.inline_login_title"), :partial => "shared/login", :id => "inlineLoginModal", :klass => "inline-login-modal"}
end

#logoutObject



40
41
42
43
# File 'frontend/app/controllers/session_controller.rb', line 40

def logout
  reset_session
  redirect_to :root
end

#select_userObject



25
26
# File 'frontend/app/controllers/session_controller.rb', line 25

def select_user
end

#token_loginObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'frontend/app/controllers/session_controller.rb', line 65

def 
  backend_session = User.(params[:username], params[:token])
  if backend_session
    # this can't prevent a determined user from using a token-acquired
    # session to do things they could do with a regular login token, but it should
    # suffice to make a typical user reset password and log back in.
    backend_session['user']['permissions'] = {}
    User.establish_session(self, backend_session, params[:username])
  else
    flash[:error] = I18n.t('login.password_update_error')
  end

  redirect_to :controller => :users, :action => :password_form
end