2012-12-02 12:29:24 +01:00
|
|
|
class ProfilesController < ApplicationController
|
2012-07-31 07:32:49 +02:00
|
|
|
before_filter :user
|
2012-12-02 12:29:24 +01:00
|
|
|
layout 'profile'
|
2012-07-31 07:32:49 +02:00
|
|
|
|
2011-10-08 23:36:38 +02:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2011-12-20 21:47:09 +01:00
|
|
|
def design
|
|
|
|
end
|
|
|
|
|
2012-12-02 12:29:24 +01:00
|
|
|
def account
|
|
|
|
end
|
|
|
|
|
2011-12-20 21:47:09 +01:00
|
|
|
def update
|
2012-12-02 12:29:24 +01:00
|
|
|
if @user.update_attributes(params[:user])
|
|
|
|
flash[:notice] = "Profile was successfully updated"
|
|
|
|
else
|
|
|
|
flash[:alert] = "Failed to update profile"
|
|
|
|
end
|
2012-11-21 21:01:40 +01:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
format.js
|
|
|
|
end
|
2011-10-20 00:34:05 +02:00
|
|
|
end
|
|
|
|
|
2012-05-19 11:00:46 +02:00
|
|
|
def token
|
|
|
|
end
|
|
|
|
|
2012-12-02 12:29:24 +01:00
|
|
|
def update_password
|
2011-10-26 15:46:25 +02:00
|
|
|
params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}
|
2011-10-08 23:36:38 +02:00
|
|
|
|
|
|
|
if @user.update_attributes(params[:user])
|
|
|
|
flash[:notice] = "Password was successfully updated. Please login with it"
|
|
|
|
redirect_to new_user_session_path
|
|
|
|
else
|
2012-11-04 22:47:37 +01:00
|
|
|
render 'account'
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
end
|
2011-11-15 14:08:20 +01:00
|
|
|
|
|
|
|
def reset_private_token
|
2012-12-02 12:29:24 +01:00
|
|
|
if current_user.reset_authentication_token!
|
|
|
|
flash[:notice] = "Token was successfully updated"
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to account_profile_path
|
2011-11-15 14:08:20 +01:00
|
|
|
end
|
2012-07-31 07:32:49 +02:00
|
|
|
|
2012-09-14 18:13:25 +02:00
|
|
|
def history
|
|
|
|
@events = current_user.recent_events.page(params[:page]).per(20)
|
|
|
|
end
|
|
|
|
|
2012-12-02 12:29:24 +01:00
|
|
|
def update_username
|
2013-01-30 21:14:34 +01:00
|
|
|
if @user.can_change_username?
|
|
|
|
@user.update_attributes(username: params[:user][:username])
|
|
|
|
end
|
2012-12-02 12:29:24 +01:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-14 18:13:25 +02:00
|
|
|
private
|
2012-07-31 07:32:49 +02:00
|
|
|
|
|
|
|
def user
|
|
|
|
@user = current_user
|
|
|
|
end
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|