File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { initializeDatabase } from "../server/db " ;
1+ import type { UserInfo } from "../common/types.ts " ;
22
33/**
44 * Hides all screens and shows only the specified one.
@@ -69,17 +69,19 @@ function initializeUI() {
6969 const messageElement = document . getElementById ( 'register-message' ) ;
7070 messageElement . textContent = '' ;
7171 messageElement . classList . remove ( 'error' ) ;
72- const alias = registerForm . elements [ 'alias' ] . value . trim ( ) ;
73- const email = registerForm . elements [ 'email' ] . value . trim ( ) ;
74- const password = registerForm . elements [ 'password' ] . value ;
7572 registerForm . classList . add ( 'loading' ) ;
76- const response = await fetch ( '/api/register' , {
73+ let response = await fetch ( '/api/register' , {
7774 method : 'POST' ,
7875 body : new FormData ( registerForm )
7976 } ) ;
8077
8178 if ( response . ok ) {
82- messageElement . textContent = `Registration successful for ${ email } ! Redirecting to login...` ;
79+ messageElement . textContent = `Registration successful! Redirecting to profile...` ;
80+ response = await fetch ( '/api/userinfo' ) ;
81+ if ( response . ok ) {
82+ const userInfo = await response . json ( ) as UserInfo ;
83+ console . log ( 'Registered user info:' , userInfo ) ;
84+ }
8385 //await new Promise(resolve => setTimeout(resolve, 1500));
8486 //showView('login-screen');
8587 } else {
Original file line number Diff line number Diff line change 11import { readFileSync } from 'fs' ;
22import type { PGInterface } from './types.ts' ;
3+ import type { User , Session } from '../common/types.ts' ;
34
4- export interface User {
5- id : number ;
6- email : string | null ;
7- username : string ;
8- hashed_password : string | null ;
9- alias : string ;
10- verification_email : string | null ;
11- created_ip_address : string ;
12- created_at : Date ;
13- active_at : Date ;
14- } ;
155export interface VerificationEmail {
166 email : string ;
177 verification_code : string ;
188 created_at : Date ;
199} ;
20- export interface Session {
21- id : number ;
22- session_key ?: string ;
23- url ?: string ;
24- user_id : number ;
25- created_at : Date ;
26- active_ip_address : string ;
27- updated_at : Date ;
28- } ;
2910
3011export async function cleanupDatabase ( client : PGInterface ) {
3112 const sqlTables = [
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ import type { ClockAPI } from '../common/interfaces.ts';
33import type { PGInterface } from './types.ts' ;
44import type { TransportInterface , LimitsConfig } from './server.ts' ;
55import { randomBytes } from 'crypto' ;
6- import type { User , VerificationEmail , Session } from './db.ts' ;
6+ import type { UserInfo , User , Session } from '../common/types.ts' ;
7+ import type { VerificationEmail } from './db.ts' ;
78
89export type RegistrationData = {
910 username : string | null ;
@@ -34,11 +35,6 @@ export type AuthenticationHandlerConfig = {
3435 limits : LimitsConfig ;
3536}
3637
37- export type UserInfo = {
38- user : User ;
39- sessions : Session [ ] ;
40- }
41-
4238const SALT_ROUNDS = 12 ;
4339
4440function generateSessionId ( ) {
You can’t perform that action at this time.
0 commit comments