forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_controller.rb
More file actions
41 lines (35 loc) · 1.21 KB
/
users_controller.rb
File metadata and controls
41 lines (35 loc) · 1.21 KB
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
class UsersController < Devise::RegistrationsController
before_filter :authenticate_user!, :except => [:auth]
respond_to :html, :json, :xml
# Overriding devise helpers
def resource_name
:user
end
# Auth endpoint
# validates a given access_token by responding with 200/401 status
def auth
# I like doing /auth?<token>
token = params[:access_token] ? params[:access_token] : params.keys.first
respond_with({status: 'unauthorized'}, :status => 401) and return if !token
@user = User.find_by_access_token(token)
respond_with({status: 'unauthorized'}, :status => 401) and return if !@user
respond_with @user
end
def dashboard
# Let the URL be ugly for now - preferable to users being confused on how
# to share their account page.
if current_user.present?
if current_user.primary_account
redirect_to :controller => 'players', :action => 'show', :id => current_user.primary_account.esdb_id, :name => current_user.primary_account.name
else
redirect_to settings_url
end
else
redirect_to :controller => :home, :action => :home
end
end
def update
current_user.update_attributes(params[:user])
render :text => "OK"
end
end