summaryrefslogtreecommitdiff
path: root/app/controllers/profile_controller.rb
blob: 38cfa896b1151bec95661dc26e373f4a66ce1881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class ProfileController < ApplicationController
  before_filter :user

  def show
  end

  def design
  end

  def update
    @user.update_attributes(params[:user])
    redirect_to :back
  end

  def token
  end

  def password_update
    params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}

    if @user.update_attributes(params[:user])
      flash[:notice] = "Password was successfully updated. Please login with it"
      redirect_to new_user_session_path
    else
      render 'account'
    end
  end

  def reset_private_token
    current_user.reset_authentication_token!
    redirect_to profile_account_path
  end

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

  private

  def user
    @user = current_user
  end
end