summaryrefslogtreecommitdiff
path: root/moneyjsx/src/login.tsx
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-17 22:39:42 +0100
committeraura <nw@moneybot.cc>2026-02-17 22:39:42 +0100
commit636b0323075225c584b62719ed51e75521bb7ffb (patch)
tree61b02271b6d0695a4beffc23fb6eb062a7da22c3 /moneyjsx/src/login.tsx
push source
Diffstat (limited to 'moneyjsx/src/login.tsx')
-rw-r--r--moneyjsx/src/login.tsx29
1 files changed, 29 insertions, 0 deletions
diff --git a/moneyjsx/src/login.tsx b/moneyjsx/src/login.tsx
new file mode 100644
index 0000000..0be6acc
--- /dev/null
+++ b/moneyjsx/src/login.tsx
@@ -0,0 +1,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>
+}