Class: ProfilesController

Inherits:
Profiles::ApplicationController
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
app/controllers/profiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#audit_logObject


35
36
37
38
39
# File 'app/controllers/profiles_controller.rb', line 35

def audit_log
  @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id).
    order("created_at DESC").
    page(params[:page])
end

#reset_private_tokenObject


27
28
29
30
31
32
33
# File 'app/controllers/profiles_controller.rb', line 27

def reset_private_token
  if current_user.reset_authentication_token!
    flash[:notice] = "Token was successfully updated"
  end

  redirect_to 
end

#showObject


8
9
# File 'app/controllers/profiles_controller.rb', line 8

def show
end

#updateObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/profiles_controller.rb', line 11

def update
  user_params.except!(:email) if @user.ldap_user?

  respond_to do |format|
    if @user.update_attributes(user_params)
      message = "Profile was successfully updated"
      format.html { redirect_back_or_default(default: { action: 'show' }, options: { notice: message }) }
      format.json { render json: { message: message } }
    else
      message = @user.errors.full_messages.uniq.join('. ')
      format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: "Failed to update profile. #{message}" }) }
      format.json { render json: { message: message }, status: :unprocessable_entity }
    end
  end
end

#update_usernameObject


41
42
43
44
45
46
47
# File 'app/controllers/profiles_controller.rb', line 41

def update_username
  @user.update_attributes(username: user_params[:username])

  respond_to do |format|
    format.js
  end
end