@belgoros wrote:
I’m using ESA implicit grant authentication. If a user is not logged in I display just an empty application template with a header containing “Login” button. When clicking on
Login
button, I redirect the user to the corporate login page:# routes/application.js actions: { login: function() { let oauthUrl = config.oauthUrl; let clientId = config.clientID; let redirectURI = `${window.location.origin}/callback`; let responseType = `token`; let scope = `profile%20openid`; window.location.replace(oauthUrl + `?client_id=${clientId}` + `&redirect_uri=${redirectURI}` + `&response_type=${responseType}` + `&scope=${scope}` ); }, logout() { this.get('session').invalidate(); } }, beforeModel() { return this._loadCurrentUser(); }, sessionAuthenticated() { this._super(...arguments); this._loadCurrentUser(); }, _loadCurrentUser() { return this.get('currentUser').loadCurrentUser().catch(() => this.get('session').invalidate()); }
I also defined
current-user.js
service as follows:# services/current-user.js import RSVP from 'rsvp'; import Service, { inject as service } from '@ember/service'; export default Service.extend({ session: service('session'), store: service(), flashMessages: service('flash-messages'), i18n: service('i18n'), currentShop: service('current-shop'), loadCurrentUser() { this.get('flashMessages').clearMessages(); if (this.get('session.isAuthenticated')) { return this.get('store').queryRecord('user', { me: true }).then((user) => { this.get('flashMessages').success(this.get('i18n').t('flash.signed_in')); this.get('currentShop').setShop(user.get('shop')); this.set('user', user); }); } else { this.get('flashMessages').info(this.get('i18n').t('flash.signed_off')); return RSVP.resolve(); } } });
How is it possible to redirect a user to the corporate login page without clicking the
Login
button ? Thank you.
Posts: 2
Participants: 2