-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow GOV.UK Admins to give themselves access to apps
This adds a "Grant access" button next to each app in the list of "Apps you don't have access to" on /account/applications. This page is currently only available to GOV.UK Admins and this functionality replicates what they're already able to do on their /users/<id>/edit page.
- Loading branch information
Showing
7 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Account::SigninPermissionsController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def create | ||
authorize :account_applications, :grant_signin_permission? | ||
|
||
application = Doorkeeper::Application.find(params[:application_id]) | ||
current_user.grant_application_signin_permission(application) | ||
redirect_to account_applications_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/controllers/account/signin_permissions_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require "test_helper" | ||
|
||
class Account::SigninPermissionsControllerTest < ActionController::TestCase | ||
should "prevent unauthenticated users from accessing create" do | ||
application = create(:application, name: "app-name", description: "app-description") | ||
|
||
post :create, params: { application_id: application.id } | ||
|
||
assert_redirected_to "/users/sign_in" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters