blob: 0be6acc45916c9f461eff90534abd095d4697377 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import $ from 'jquery';
import * as JSX from './jsx';
import * as user from './user';
import { GroupBox, Page } from './components';
export default function Login() {
if( user.is_loggedin )
return JSX.navigateParams( "/", {} );
const url = new URL( window.location.href );
const code = url.searchParams.get( "token" );
let msg = "You should be redirected shortly...";
if( !code ) {
msg = "The link you followed is invalid.";
}
else {
user.onLogin( code ).then( () => {
JSX.navigateParams( '/terminal', {} );
} ).catch( ( e: any ) => {
$( "#login-msg" ).text( e.message );
} );
}
return <Page>
<GroupBox title="Login">
<span id="login-msg">{ msg }</span>
</GroupBox>
</Page>
}
|