11import Route from '@ember/routing/route' ;
2- import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin' ;
32import UTMCookieRouteMixin from 'hackerblocks/mixins/utm-cookie-route-mixin' ;
43import { inject as service } from '@ember/service' ;
54import { isNone } from '@ember/utils' ;
65import config from 'hackerblocks/config/environment'
76
8- export default Route . extend ( ApplicationRouteMixin , UTMCookieRouteMixin , {
7+ export default Route . extend ( UTMCookieRouteMixin , {
98 session : service ( ) ,
109 currentUser : service ( ) ,
1110 queryParams : {
@@ -28,31 +27,11 @@ export default Route.extend(ApplicationRouteMixin, UTMCookieRouteMixin, {
2827
2928 async beforeModel ( transition ) {
3029 this . _super ( ...arguments )
31- if ( ! isNone ( transition . to . queryParams . code ) ) {
32- if ( this . get ( 'session.isAuthenticated' ) ) {
33- return this . transitionTo ( 'index' , { queryParams : { code : undefined } } )
34- }
35- // we have ?code qp
36- const { code } = transition . to . queryParams
37-
38- try {
39- await (
40- this . session . authenticate ( 'authenticator:jwt' , { identification : code , password : code , code } )
41- . then ( ( ) => this . currentUser . load ( ) )
42- )
43- return this . transitionTo ( 'index' , { queryParams : { code : undefined } } )
44- } catch ( error ) {
45- console . log ( error )
46- if ( error . json . err === 'USER_EMAIL_NOT_VERIFIED' ) {
47- this . transitionTo ( 'error' , {
48- queryParams : {
49- errorCode : 'USER_EMAIL_NOT_VERIFIED' ,
50- code : undefined
51- }
52- } )
53- }
54- }
30+
31+ if ( ! this . session . isAuthenticated ) {
32+ window . location . href = config . nuxtPublicUrl
5533 }
34+
5635 } ,
5736
5837 async model ( ) {
0 commit comments