File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 < div class ="modal ">
99 < div class ="title "> Dev options</ div >
1010 < button class ="generateData "> generate data</ button >
11+ < button class ="quickLogin "> quick login</ button >
1112 < button class ="toggleMediaQueryDebug "> toggle media query debug</ button >
1213 < button class ="showTestNotifications "> show test notifications</ button >
1314 < button class ="showRealWordsInput "> show real words input</ button >
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ type Config = {
33 isDevelopment : boolean ;
44 clientVersion : string ;
55 recaptchaSiteKey : string ;
6+ quickLoginEmail : string | undefined ;
7+ quickLoginPassword : string | undefined ;
68} ;
79
810//@ts -expect-error these get replaced by vite
@@ -13,10 +15,16 @@ const isDevelopment = IS_DEVELOPMENT;
1315const clientVersion = CLIENT_VERSION ;
1416// @ts -expect-error
1517const recaptchaSiteKey = RECAPTCHA_SITE_KEY ;
18+ // @ts -expect-error
19+ const quickLoginEmail = QUICK_LOGIN_EMAIL ;
20+ // @ts -expect-error
21+ const quickLoginPassword = QUICK_LOGIN_PASSWORD ;
1622
1723export const envConfig : Config = {
1824 backendUrl,
1925 isDevelopment,
2026 clientVersion,
2127 recaptchaSiteKey,
28+ quickLoginEmail,
29+ quickLoginPassword,
2230} ;
Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ if (Auth && ConnectionState.get()) {
276276 } ) ;
277277}
278278
279- async function signIn ( ) : Promise < void > {
279+ export async function signIn ( email : string , password : string ) : Promise < void > {
280280 if ( Auth === undefined ) {
281281 Notifications . add ( "Authentication uninitialized" , - 1 ) ;
282282 return ;
@@ -292,8 +292,6 @@ async function signIn(): Promise<void> {
292292 LoginPage . showPreloader ( ) ;
293293 LoginPage . disableInputs ( ) ;
294294 LoginPage . disableSignUpButton ( ) ;
295- const email = ( $ ( ".pageLogin .login input" ) [ 0 ] as HTMLInputElement ) . value ;
296- const password = ( $ ( ".pageLogin .login input" ) [ 1 ] as HTMLInputElement ) . value ;
297295
298296 if ( email === "" || password === "" ) {
299297 Notifications . add ( "Please fill in all fields" , 0 ) ;
@@ -627,7 +625,11 @@ async function signUp(): Promise<void> {
627625
628626$ ( ".pageLogin .login form" ) . on ( "submit" , ( e ) => {
629627 e . preventDefault ( ) ;
630- void signIn ( ) ;
628+ const email =
629+ ( $ ( ".pageLogin .login input" ) [ 0 ] as HTMLInputElement ) . value ?? "" ;
630+ const password =
631+ ( $ ( ".pageLogin .login input" ) [ 1 ] as HTMLInputElement ) . value ?? "" ;
632+ void signIn ( email , password ) ;
631633} ) ;
632634
633635$ ( ".pageLogin .login button.signInWithGoogle" ) . on ( "click" , ( ) => {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import AnimatedModal from "../utils/animated-modal";
33import { showPopup } from "./simple-modals" ;
44import * as Notifications from "../elements/notifications" ;
55import { setMediaQueryDebugLevel } from "../ui" ;
6+ import { signIn } from "../controllers/account-controller" ;
67
78let mediaQueryDebugLevel = 0 ;
89
@@ -47,6 +48,20 @@ async function setup(modalEl: HTMLElement): Promise<void> {
4748 $ ( "#wordsInput" ) . css ( "opacity" , "1" ) ;
4849 void modal . hide ( ) ;
4950 } ) ;
51+ modalEl . querySelector ( ".quickLogin" ) ?. addEventListener ( "click" , ( ) => {
52+ if (
53+ envConfig . quickLoginEmail === undefined ||
54+ envConfig . quickLoginPassword === undefined
55+ ) {
56+ Notifications . add (
57+ "Quick login credentials not set. Add QUICK_LOGIN_EMAIL and QUICK_LOGIN_PASSWORD to your frontend .env file." ,
58+ - 1
59+ ) ;
60+ return ;
61+ }
62+ void signIn ( envConfig . quickLoginEmail , envConfig . quickLoginPassword ) ;
63+ void modal . hide ( ) ;
64+ } ) ;
5065}
5166
5267const modal = new AnimatedModal ( {
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ export default {
3737 RECAPTCHA_SITE_KEY : JSON . stringify (
3838 "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
3939 ) ,
40+ QUICK_LOGIN_EMAIL : JSON . stringify ( process . env . QUICK_LOGIN_EMAIL ) ,
41+ QUICK_LOGIN_PASSWORD : JSON . stringify ( process . env . QUICK_LOGIN_PASSWORD ) ,
4042 } ,
4143 build : {
4244 outDir : "../dist" ,
You can’t perform that action at this time.
0 commit comments