refactor: 💡 "retry" is a link instead of an action button
This commit is contained in:
4 files changed
+61
-22
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeAuthenticateMethodOidcController extends Controller {
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Authetnication URL for the pending OIDC flow, if any.
|
||||
* @type {?string}
|
||||
*/
|
||||
get authURL() {
|
||||
return this.session.data.pending.oidc.attributes.auth_url;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,27 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
return this.store.findRecord('auth-method', id, adapterOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async startOIDCAuthentication(authenticatorName, options) {
|
||||
const oidc = getOwner(this).lookup(authenticatorName);
|
||||
// TODO: delegate this call from the session service so that we don't have
|
||||
// to look up the authenticator directly
|
||||
const json = await oidc.startAuthentication(options);
|
||||
await this.openExternalOIDCFlow(json.attributes.auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified URL in a new tab or window. By default this uses
|
||||
* `window.open`, but may be overriden.
|
||||
* @param {string} url
|
||||
*/
|
||||
async openExternalOIDCFlow(url) {
|
||||
// TODO don't use window directly
|
||||
await window.open(url);
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
@@ -57,25 +78,4 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async startOIDCAuthentication(authenticatorName, options) {
|
||||
const oidc = getOwner(this).lookup(authenticatorName);
|
||||
// TODO: delegate this call from the session service so that we don't have
|
||||
// to look up the authenticator directly
|
||||
const json = await oidc.startAuthentication(options);
|
||||
await this.openExternalOIDCFlow(json.attributes.auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified URL in a new tab or window. By default this uses
|
||||
* `window.open`, but may be overriden.
|
||||
* @param {string} url
|
||||
*/
|
||||
async openExternalOIDCFlow(url) {
|
||||
// TODO don't use window directly
|
||||
await window.open(url);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,11 @@
|
||||
<p>{{t 'resources.auth-method.messages.pending.description'}}</p>
|
||||
<p>
|
||||
{{t 'resources.auth-method.questions.no-see-window'}}
|
||||
<a role="button" href="#" {{on "click" (route-action "authenticate")}}>
|
||||
<a
|
||||
href="{{this.authURL}}"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
{{t 'actions.retry'}}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/authenticate/method/oidc',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/authenticate/method/oidc'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user