{"action":"created","issue":{"url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9","repository_url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp","labels_url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9/comments","events_url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9/events","html_url":"https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9","id":251568811,"number":9,"title":"Forgot password policy","user":{"login":"DibranMulder","id":5592416,"avatar_url":"https://avatars1.githubusercontent.com/u/5592416?v=4","gravatar_id":"","url":"https://api.github.com/users/DibranMulder","html_url":"https://github.com/DibranMulder","followers_url":"https://api.github.com/users/DibranMulder/followers","following_url":"https://api.github.com/users/DibranMulder/following{/other_user}","gists_url":"https://api.github.com/users/DibranMulder/gists{/gist_id}","starred_url":"https://api.github.com/users/DibranMulder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DibranMulder/subscriptions","organizations_url":"https://api.github.com/users/DibranMulder/orgs","repos_url":"https://api.github.com/users/DibranMulder/repos","events_url":"https://api.github.com/users/DibranMulder/events{/privacy}","received_events_url":"https://api.github.com/users/DibranMulder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-08-21T07:13:39Z","updated_at":"2017-09-26T07:54:34Z","closed_at":null,"author_association":"NONE","body":"When using a combined signup - signin policy in Azure B2C, users have to handle the forgot password scenario themselves. Please take a look at the [documentation](https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-policies).\r\n\r\n> How do I link a sign-up or sign-in policy with a password reset policy?\r\n> When you create a sign-up or sign-in policy (with local accounts), you see a Forgot password? link on the first page of the experience. Clicking this link doesn't automatically trigger a password reset policy.\r\n> Instead, the error code AADB2C90118 is returned to your app. Your app needs to handle this error code by invoking a specific password reset policy. For more information, see a sample that demonstrates the approach of linking policies.\r\n\r\nI managed to redirect the page to the forgot password policy when that error with error_description AADB2C90118 occurs. However when the user then successfully resets his or hers password I'm not able to login the user, it seems that the authority's do not match since the policy names are included in the authority names. Can you please include the forgot password scenario in your samples?"},"comment":{"url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/comments/332116904","html_url":"https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9#issuecomment-332116904","issue_url":"https://api.github.com/repos/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/9","id":332116904,"user":{"login":"jcarloslr10","id":15978818,"avatar_url":"https://avatars0.githubusercontent.com/u/15978818?v=4","gravatar_id":"","url":"https://api.github.com/users/jcarloslr10","html_url":"https://github.com/jcarloslr10","followers_url":"https://api.github.com/users/jcarloslr10/followers","following_url":"https://api.github.com/users/jcarloslr10/following{/other_user}","gists_url":"https://api.github.com/users/jcarloslr10/gists{/gist_id}","starred_url":"https://api.github.com/users/jcarloslr10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcarloslr10/subscriptions","organizations_url":"https://api.github.com/users/jcarloslr10/orgs","repos_url":"https://api.github.com/users/jcarloslr10/repos","events_url":"https://api.github.com/users/jcarloslr10/events{/privacy}","received_events_url":"https://api.github.com/users/jcarloslr10/received_events","type":"User","site_admin":false},"created_at":"2017-09-26T07:54:33Z","updated_at":"2017-09-26T07:54:33Z","author_association":"NONE","body":"@Chakravarti-Baratam I got it to work with this code for the UserAgentApplication initialization\r\n\r\n```\r\nthis._app = new Msal.UserAgentApplication(this._tenantConfig.clientId, this._tenantConfig.authority,\r\n            (errorDesc, token, error, tokenType) => {\r\n                this._storageService.save(this._b2cErrorKey, errorDesc);\r\n                console.log('after loginredirect or acquireTokenPopup');\r\n            });\r\n```\r\nand\r\n\r\n```\r\nlogin(): any {\r\n        return this._app.acquireTokenSilent(this._tenantConfig.scopes)\r\n            .then(accessToken => {\r\n                this._isLogged = true;\r\n                this._access_token = accessToken;\r\n                return accessToken;\r\n            }, error => {\r\n                this.redirectIfForgotPassword();\r\n                return this._app.loginRedirect(this._tenantConfig.scopes, `ui_locales=${this._languageService.currentLanguage}`)\r\n                    .then(accessToken => {\r\n                        this._access_token = accessToken;\r\n                        return accessToken;\r\n                    }, err => {\r\n                        console.error(err);\r\n                    });\r\n            });\r\n    }\r\n\r\nredirectIfForgotPassword(): void {\r\n        const errorDesc = this._storageService.get(this._b2cErrorKey);\r\n        if (errorDesc && errorDesc.indexOf('AADB2C90118') > -1) {\r\n            const authUrlSplit = this._tenantConfig.authority.split('/');\r\n            const authorityUrl =\r\n                `${authUrlSplit.slice(0, authUrlSplit.length - 1).join('/')}/${environment.b2c.passwordResetPolicy}`;\r\n\r\n            this._app.authority = authorityUrl;\r\n            this._storageService.remove(this._b2cErrorKey);\r\n            \r\n            this.login();\r\n        }\r\n    }\r\n```\r\nfor login and redirect methods. This will allow you to change the policy without getting null value for UserAgentApplication object. I'm not found any better solution. @parakhj when will you have the final examples?\r\n\r\nThanks!!"}}
{"actor":{"display_login":"jcarloslr10"}}