[Fix #1100] Administrateur can renew his API Token
This commit is contained in:
parent
260858076e
commit
98ac496aa5
4 changed files with 20 additions and 0 deletions
|
@ -2,4 +2,10 @@ class Admin::ProfileController < AdminController
|
|||
def show
|
||||
@administrateur = current_administrateur
|
||||
end
|
||||
|
||||
def renew_api_token
|
||||
flash[:notice] = "Votre token d'API a été regénéré."
|
||||
current_administrateur.renew_api_token
|
||||
redirect_to admin_profile_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,3 +4,5 @@
|
|||
%p
|
||||
API TOKEN :
|
||||
= @administrateur.api_token
|
||||
%p
|
||||
= link_to "Regénérer mon token", admin_renew_api_token_path, method: :post, class: "btn btn-default", data: { confirm: "Confirmez-vous la regénération de votre token ? Les applications qui l'utilisent actuellement seront bloquées.", disable_with: "Regénération..." }
|
||||
|
|
|
@ -110,6 +110,7 @@ Rails.application.routes.draw do
|
|||
get 'procedures/draft' => 'procedures#draft'
|
||||
get 'procedures/path_list' => 'procedures#path_list'
|
||||
get 'profile' => 'profile#show', as: :profile
|
||||
post 'renew_api_token' => 'profile#renew_api_token', as: :renew_api_token
|
||||
|
||||
get 'change_dossier_state' => 'change_dossier_state#index'
|
||||
post 'change_dossier_state' => 'change_dossier_state#check'
|
||||
|
|
|
@ -2,4 +2,15 @@ require 'spec_helper'
|
|||
|
||||
describe Admin::ProfileController, type: :controller do
|
||||
it { expect(described_class).to be < AdminController }
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before { sign_in(administrateur) }
|
||||
|
||||
describe 'POST #renew_api_token' do
|
||||
subject { post :renew_api_token }
|
||||
|
||||
it { expect{ subject }.to change{ administrateur.reload.api_token } }
|
||||
|
||||
it { subject; expect(response.status).to redirect_to(admin_profile_path) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue