diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-02-02 12:03:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 12:03:49 +0100 |
commit | 20a479ff7c3bcd8e5c223dae53b30b174d87f1bf (patch) | |
tree | 434a876c31275eb3be5f9d538801f85955e32f65 | |
parent | 6a5e447753095606e42cc3899887ba7fae77a0e8 (diff) |
Change `POST /settings/applications/:id` to regenerate token on scopes change (#23359)
Fixes #23096
-rw-r--r-- | app/controllers/settings/applications_controller.rb | 8 | ||||
-rw-r--r-- | spec/controllers/settings/applications_controller_spec.rb | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/settings/applications_controller.rb b/app/controllers/settings/applications_controller.rb index d3ac268d8..e6e137c2b 100644 --- a/app/controllers/settings/applications_controller.rb +++ b/app/controllers/settings/applications_controller.rb @@ -29,7 +29,13 @@ class Settings::ApplicationsController < Settings::BaseController def update if @application.update(application_params) - redirect_to settings_applications_path, notice: I18n.t('generic.changes_saved_msg') + if @application.scopes_previously_changed? + @access_token = current_user.token_for_app(@application) + @access_token.destroy + redirect_to settings_application_path(@application), notice: I18n.t('applications.token_regenerated') + else + redirect_to settings_application_path(@application), notice: I18n.t('generic.changes_saved_msg') + end else render :show end diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 29c278148..1292e9ff8 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -132,7 +132,7 @@ describe Settings::ApplicationsController do end it 'redirects back to applications page' do - expect(call_update).to redirect_to(settings_applications_path) + expect(call_update).to redirect_to(settings_application_path(app)) end end |