MCPcopy Create free account
hub / github.com/Milkyroad/SCiPNET / registerProcess

Function registerProcess

public/src/js/register.js:20–147  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

18window.keyReg = "";
19
20export const registerProcess = (val) => {
21 //register user through firebase auth
22 var valCase = val;
23 val = val.toLowerCase().trim()
24 if (val == "quit") {
25 btnShow()
26 appendNormal("Registration process exited")
27 registerState = 0
28 userReg = "";
29 clrReg = "";
30 titleReg = "";
31 emailReg = "";
32 passReg = "";
33 classReg = "";
34 siteReg = "";
35 keyReg = ""
36 } else {
37 if (val.includes("|-|") || val.includes("/")) {
38 appendError('INPUT CONTAINS ILLEGAL STRING "|-|" or "/", PLEASE AVOID INCLUDING THIS STRING IN YOUR INPUT AND TRY AGAIN')
39 } else {
40 if (registerState == 1) {
41 if (val == "y") {
42 appendNormal(`<hr><span class="redLabels">Registration Protocol initiated</span><br><span style="color:#98FB98">[✓] </span>Registration confirmed<br>Please enter your username as your identity in the Foundation's database<hr>`)
43 registerState = 2
44 } else if (val == "n") {
45 appendNormal("Registration aborted, request for registration has been discarded")
46 btnShow()
47 registerState = 0
48 } else {
49 appendError(`UNRECOGNISED INPUT, PLEASE ENTER "Y", "N" OR "Quit"`)
50 }
51 } else if (registerState == 2) {
52 if (valCase.length < 101) {
53 userReg = valCase
54 appendNormal("Please enter your email address you wish to register with")
55 registerState = 2.5
56 } else {
57 appendError("USERNAME TOO LONG, PLEASE CHOOSE ANOTHER ONE.")
58 registerState = 2
59 }
60 } else if (registerState == 2.5) {
61 cmdHide()
62 firebase.auth().fetchSignInMethodsForEmail(valCase)
63 .then((signInMethods) => {
64 if (signInMethods.length) {
65 cmdShow()
66 registerState = 2.5
67 appendError('WE ALREADY HAVE AN USER WITH A CORRESPONDING EMAIL ADDRESS IN OUR DATABASE. PLEASE USE ANOTHER EMAIL OR TRY LOGGING IN<br><hr><small style="opacity:0.7">If you wish to login, enter "Quit" to exit the registration process. After that, enter "Login" to login yourself.</small>')
68 } else {
69 emailReg = val
70 registerState = 3
71 registerProcess("clearance")
72 }
73 })
74 .catch((error) => {
75 cmdShow()
76 appendError(`${String(error).toUpperCase()}<br><hr> <small style='opacity:0.7'>PLEASE TRY AGAIN.</small>`)
77 registerState = 2.5

Callers 1

script.jsFile · 0.85

Calls 9

btnShowFunction · 0.90
appendNormalFunction · 0.90
appendErrorFunction · 0.90
cmdHideFunction · 0.90
cmdShowFunction · 0.90
addDotFunction · 0.90
personnellistClickFunction · 0.85
registerUserWithInfoFunction · 0.85
$Function · 0.50

Tested by

no test coverage detected