BigW Consortium Gitlab

profiles_controller.rb 1.13 KB
Newer Older
1
class ProfilesController < ApplicationController
2 3
  include ActionView::Helpers::SanitizeHelper

4
  before_filter :user
5 6
  before_filter :authorize_change_username!, only: :update_username

7
  layout 'profile'
8

gitlabhq committed
9 10 11
  def show
  end

12 13 14 15
  def design
  end

  def update
16 17
    params[:user].delete(:email) if @user.ldap_user?

18
    if @user.update_attributes(params[:user])
19 20 21 22
      flash[:notice] = "Profile was successfully updated"
    else
      flash[:alert] = "Failed to update profile"
    end
23 24 25 26 27

    respond_to do |format|
      format.html { redirect_to :back }
      format.js
    end
28 29
  end

30
  def reset_private_token
31 32 33 34
    if current_user.reset_authentication_token!
      flash[:notice] = "Token was successfully updated"
    end

35
    redirect_to profile_account_path
36
  end
37

38 39 40 41
  def history
    @events = current_user.recent_events.page(params[:page]).per(20)
  end

42
  def update_username
43
    @user.update_attributes(username: params[:user][:username])
44 45 46 47 48 49

    respond_to do |format|
      format.js
    end
  end

50
  private
51 52 53 54

  def user
    @user = current_user
  end
55

56 57 58
  def authorize_change_username!
    return render_404 unless @user.can_change_username?
  end
gitlabhq committed
59
end