github.com/hernad/nomad@v1.6.112/ui/app/controllers/oidc-mock.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Controller from '@ember/controller'; 7 import { action } from '@ember/object'; 8 import { inject as service } from '@ember/service'; 9 import Ember from 'ember'; 10 11 export default class OidcMockController extends Controller { 12 @service router; 13 14 queryParams = ['auth_method', 'client_nonce', 'redirect_uri', 'meta']; 15 16 @action 17 signIn(fakeAccount) { 18 const url = `${this.redirect_uri.split('?')[0]}?code=${ 19 fakeAccount.accessor 20 }&state=success`; 21 if (Ember.testing) { 22 this.router.transitionTo(url); 23 } else { 24 window.location = url; 25 } 26 } 27 28 @action 29 failToSignIn() { 30 const url = `${this.redirect_uri.split('?')[0]}?state=failure`; 31 if (Ember.testing) { 32 this.router.transitionTo(url); 33 } else { 34 window.location = url; 35 } 36 } 37 }