@@ -253,6 +253,10 @@ export default {
253253 hideLocal: {
254254 type: Boolean ,
255255 default: false
256+ },
257+ changePwdContinuationToken: {
258+ type: String ,
259+ default: null
256260 }
257261 },
258262 data () {
@@ -309,6 +313,9 @@ export default {
309313 },
310314 selectedStrategyKey (newValue , oldValue ) {
311315 this .selectedStrategy = _ .find (this .strategies , [' key' , newValue])
316+ if (this .screen === ' changePwd' ) {
317+ return
318+ }
312319 this .screen = ' login'
313320 if (! this .selectedStrategy .strategy .useForm ) {
314321 this .isLoading = true
@@ -322,6 +329,10 @@ export default {
322329 },
323330 mounted () {
324331 this .isShown = true
332+ if (this .changePwdContinuationToken ) {
333+ this .screen = ' changePwd'
334+ this .continuationToken = this .changePwdContinuationToken
335+ }
325336 },
326337 methods: {
327338 /**
@@ -475,32 +486,51 @@ export default {
475486 this .loaderColor = ' grey darken-4'
476487 this .loaderTitle = this .$t (' auth:changePwd.loading' )
477488 this .isLoading = true
478- const resp = await this .$apollo .mutate ({
479- mutation: gql `
480- {
481- authentication {
482- activeStrategies {
483- key
489+ try {
490+ const resp = await this .$apollo .mutate ({
491+ mutation: gql `
492+ mutation (
493+ $continuationToken : String !
494+ $newPassword : String !
495+ ) {
496+ authentication {
497+ loginChangePassword (
498+ continuationToken : $continuationToken
499+ newPassword : $newPassword
500+ ) {
501+ responseResult {
502+ succeeded
503+ errorCode
504+ slug
505+ message
506+ }
507+ jwt
508+ continuationToken
509+ redirect
510+ }
484511 }
485512 }
513+ ` ,
514+ variables: {
515+ continuationToken: this .continuationToken ,
516+ newPassword: this .newPassword
486517 }
487- ` ,
488- variables: {
489- continuationToken: this .continuationToken ,
490- newPassword: this .newPassword
518+ })
519+ if (_ .has (resp, ' data.authentication.loginChangePassword' )) {
520+ let respObj = _ .get (resp, ' data.authentication.loginChangePassword' , {})
521+ if (respObj .responseResult .succeeded === true ) {
522+ this .handleLoginResponse (respObj)
523+ } else {
524+ throw new Error (respObj .responseResult .message )
525+ }
526+ } else {
527+ throw new Error (this .$t (' auth:genericError' ))
491528 }
492- })
493- if (_ .get (resp, ' data.authentication.loginChangePassword.responseResult.succeeded' , false ) === true ) {
494- this .loaderColor = ' green darken-1'
495- this .loaderTitle = this .$t (' auth:loginSuccess' )
496- Cookies .set (' jwt' , _ .get (resp, ' data.authentication.loginChangePassword.jwt' , ' ' ), { expires: 365 })
497- _ .delay (() => {
498- window .location .replace (' /' ) // TEMPORARY - USE RETURNURL
499- }, 1000 )
500- } else {
529+ } catch (err) {
530+ console .error (err)
501531 this .$store .commit (' showNotification' , {
502532 style: ' red' ,
503- message: _ . get (resp, ' data.authentication.loginChangePassword.responseResult. message' , false ) ,
533+ message: err . message ,
504534 icon: ' alert'
505535 })
506536 this .isLoading = false
@@ -519,11 +549,57 @@ export default {
519549 * FORGOT PASSWORD SUBMIT
520550 */
521551 async forgotPasswordSubmit () {
522- this .$store .commit (' showNotification' , {
523- style: ' pink' ,
524- message: ' Coming soon!' ,
525- icon: ' ferry'
526- })
552+ this .loaderColor = ' grey darken-4'
553+ this .loaderTitle = this .$t (' auth:forgotPasswordLoading' )
554+ this .isLoading = true
555+ try {
556+ const resp = await this .$apollo .mutate ({
557+ mutation: gql `
558+ mutation (
559+ $email : String !
560+ ) {
561+ authentication {
562+ forgotPassword (
563+ email : $email
564+ ) {
565+ responseResult {
566+ succeeded
567+ errorCode
568+ slug
569+ message
570+ }
571+ }
572+ }
573+ }
574+ ` ,
575+ variables: {
576+ email: this .username
577+ }
578+ })
579+ if (_ .has (resp, ' data.authentication.forgotPassword.responseResult' )) {
580+ let respObj = _ .get (resp, ' data.authentication.forgotPassword.responseResult' , {})
581+ if (respObj .succeeded === true ) {
582+ this .$store .commit (' showNotification' , {
583+ style: ' success' ,
584+ message: this .$t (' auth:forgotPasswordSuccess' ),
585+ icon: ' email'
586+ })
587+ this .screen = ' login'
588+ } else {
589+ throw new Error (respObj .message )
590+ }
591+ } else {
592+ throw new Error (this .$t (' auth:genericError' ))
593+ }
594+ } catch (err) {
595+ console .error (err)
596+ this .$store .commit (' showNotification' , {
597+ style: ' red' ,
598+ message: err .message ,
599+ icon: ' alert'
600+ })
601+ }
602+ this .isLoading = false
527603 },
528604 handleLoginResponse (respObj ) {
529605 this .continuationToken = respObj .continuationToken
0 commit comments