Class: AuthorizationsController
Instance Method Summary
collapse
#after_sign_in_path_for, #api_authenticate!, #authenticated_via_token?, #current_project, #expire_revision!, #followed_projects, #no_cache, #oauth_authorize!, #read_revision, #require_login, #return_or_cache_revision!, #revision, #token_authenticate!, #unfurling?, #with_current_project
Methods included from UrlHelper
#feature_path, #link_to_project_feature
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/authorizations_controller.rb', line 24
def create
@authorization = current_user.authorizations.build(params[:authorization])
authorize! :create, @authorization
if @authorization.save
redirect_to my_authorizations_path
else
render action: :new, error: @authorization.errors.full_messages.to_sentence
end
end
|
#destroy ⇒ Object
50
51
52
53
54
55
|
# File 'app/controllers/authorizations_controller.rb', line 50
def destroy
authorize! :destroy, @authorization
@authorization.destroy
redirect_to my_authorizations_path, notice: "Authorization to #{@authorization.provider.name} revoked"
end
|
#edit ⇒ Object
35
36
37
38
|
# File 'app/controllers/authorizations_controller.rb', line 35
def edit
@title = "Edit Authorization"
authorize! :update, @authorization
end
|
#grant ⇒ Object
57
58
59
60
61
62
63
|
# File 'app/controllers/authorizations_controller.rb', line 57
def grant
if @authorization.granted?
redirect_to authorizations_url, notice: "Already Granted"
else
redirect_to @authorization.authorize_url
end
end
|
#granted ⇒ Object
74
75
76
|
# File 'app/controllers/authorizations_controller.rb', line 74
def granted
redirect_to session[granted_redirect] if session.key?(granted_redirect)
end
|
#index ⇒ Object
5
6
7
8
9
|
# File 'app/controllers/authorizations_controller.rb', line 5
def index
@title = "Authorizations"
authorize! :read, :all_authorizations
@authorizations = Authorization.all.preload(:user)
end
|
#mine ⇒ Object
11
12
13
14
15
16
|
# File 'app/controllers/authorizations_controller.rb', line 11
def mine
@title = "My Authorizations"
authorize! :create, Authorization
@authorizations = current_user.authorizations
render action: :index
end
|
#new ⇒ Object
18
19
20
21
22
|
# File 'app/controllers/authorizations_controller.rb', line 18
def new
@title = "New Authorization"
authorize! :create, Authorization
@authorization = Authorization.new
end
|
#oauth2_callback ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'app/controllers/authorizations_controller.rb', line 65
def oauth2_callback
if params.key?(:code) && params.key?(:state)
authorization = Authorization.set_access_token! params
redirect_to authorization_granted_url(authorization)
else
@error = params.fetch(:error, "An unknown error occurred")
end
end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/authorizations_controller.rb', line 40
def update
authorize! :update, @authorization
if @authorization.update_attributes(params[:authorization])
redirect_to my_authorizations_path
else
render action: :new
end
end
|