Private Sub btnSignUp_Click (e As BANanoEvent)
e.PreventDefault
'reset the validations
mdlSignIn.ResetValidation
'validate each of the elements
mdlSignIn.Validate(fullname.IsBlank)
mdlSignIn.Validate(email.IsBlank)
mdlSignIn.Validate(password.IsBlank)
mdlSignIn.Validate(confirmpassword.IsBlank)
'check the form status
If mdlSignIn.IsValid = False Then Return
'get the data on form
'
app.pagepause
Dim bmabeauty As Map = banano.Await(banano.GetFileAsJSON($"./assets/bmabeauty.json?${DateTime.now}"$, Null))
Dim ex As String = bmabeauty.Get("e")
Dim px As String = bmabeauty.Get("p")
dblUsers.Initialize(Me, "dbusers", Main.ServerIP, "users")
banano.await(dblUsers.ADMIN_AUTH_WITH_PASSWORD(ex, px))
Dim admin As profileType = dblUsers.UserProfile
If admin.Size = 0 Then
app.pageresume
app.ShowSwalError("The Administrator could not sign in, please try again later!")
Return
End If
'generate a password
Dim user As Map = CreateMap()
user.put("email", email.value)
user.put("password", password.value)
user.put("passwordConfirm", confirmpassword.value)
user.put("name", fullname.value)
banano.Await(dblUsers.CREATE_USER(user))
Dim up As profileType = dblUsers.UserProfile
If up.size = 0 Then
app.pageresume
app.ShowSwalError($"${fullname.value}, user could not be created, please try again later!"$)
Return
Else
banano.Await(dblUsers.USER_REQUEST_VERIFICATION(email.value))
banano.Await(dblUsers.USER_AUTH_WITH_PASSWORD(email.Value, password.value))
app.pageresume
app.ShowSwalSuccess($"${fullname.value} user account was created successfully!"$)
End If
End Sub