@@ -7,20 +7,23 @@ import { Endpoints } from "../constants/Endpoints";
7
7
*/
8
8
const handleLogin = ( redirect_uri ?: string ) => {
9
9
10
- // if no uri specified to redirect to after login, then fallback to current location
11
- let final_redirect_uri = redirect_uri as string ;
12
- if ( ! redirect_uri ) {
13
- final_redirect_uri = window . location . href ;
14
- }
10
+ // if no uri specified to redirect to after login, then fallback to current location
11
+ let final_redirect_uri = redirect_uri as string ;
12
+ if ( ! redirect_uri ) {
13
+ final_redirect_uri = window . location . href ;
14
+ }
15
15
16
- // save redirect uri for later (post-login)
17
- localStorage . setItem ( 'login_redirect_uri' , final_redirect_uri ) ;
16
+ // save redirect uri for later (post-login)
17
+ localStorage . setItem ( 'login_redirect_uri' , final_redirect_uri ) ;
18
18
19
- // oauth provider chosen (currently no parameter as github is the only one)
20
- const client_id = import . meta. env . VITE_GITHUB_APP_CLIENT_ID ;
19
+ // oauth provider chosen (currently no parameter as github is the only one)
20
+ const client_id = import . meta. env . VITE_GITHUB_APP_CLIENT_ID ;
21
21
22
- // redirect user to login endpoint with client id
23
- window . location . href = `${ Endpoints . gitHubLoginUrl } ?client_id=${ client_id } ` ;
22
+ const redirectUri = `${ Endpoints . galleryAuthRedirectUrl } ?provider=github&redirect_url=${ window . location . origin } ` ;
23
+ const encodedRedirectUri = encodeURIComponent ( redirectUri ) ;
24
+ // redirect user to login endpoint with client id
25
+ window . location . href = `${ Endpoints . gitHubLoginUrl } ?client_id=${ client_id } &redirect_uri=${ encodedRedirectUri } ` ;
24
26
}
25
27
26
- export { handleLogin }
28
+ export { handleLogin } ;
29
+
0 commit comments