File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7676 const lookupKey = urlParams . get ( 'lookupKey' )
7777 const hasEmail = Boolean ( email )
7878 const hasLookupKey = Boolean ( lookupKey )
79+ const isEmailPasswordRecovery = mode === 'emailpassword'
80+
81+ const decodeLoginEntropy = ( loginValue ) => {
82+ try {
83+ // Handle URL-safe base64 tokens and missing padding.
84+ const normalizedLogin = loginValue . replace ( / - / g, '+' ) . replace ( / _ / g, '/' )
85+ const padding = '=' . repeat ( ( 4 - ( normalizedLogin . length % 4 ) ) % 4 )
86+ return atob ( normalizedLogin + padding )
87+ } catch {
88+ return null
89+ }
90+ }
7991
80- let entropy = null
8192 if ( login ) {
82- entropy = atob ( login )
83- window . localStorage . setItem ( 'hedgehog-entropy-key' , entropy )
93+ if ( ! isEmailPasswordRecovery ) {
94+ const entropy = decodeLoginEntropy ( login )
95+ if ( entropy ) {
96+ window . localStorage . setItem ( 'hedgehog-entropy-key' , entropy )
97+ }
98+ }
8499 let redirectUrl = location . protocol + '//' + location . host
85100 if ( useHashRouting ) {
86101 redirectUrl += '/#'
89104 window . history . replaceState ( { } , document . title , redirectUrl )
90105 }
91106
92- const isEmailPasswordRecovery = mode === 'emailpassword'
93107 const isPasswordRecovery =
94108 ! isEmailPasswordRecovery &&
95109 ( warning === 'RECOVERY_DO_NOT_SHARE' || mode === 'password' )
You can’t perform that action at this time.
0 commit comments