Exemple #1
0
        /// <summary>
        /// Login command
        /// </summary>
        /// <param name="loginrequest"></param>
        public void LoginCom(AuthenticateRequest loginrequest)
        {
            //serialized input
            string sinput = JsonSerializer.Serialize(loginrequest);

            Task <HttpResponseMessage> loginresponse = APIHelper.ApiCall("Accounts/authenticate", HttpMethod.Post, sinput);

            HttpResponseMessage response = loginresponse.Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                AuthenticateResponse authresp = response.Content.ReadAsAsync <AuthenticateResponse>().Result;

                if (authresp.IsVerified)
                {
                    //User is authenticated


                    //close login window
                    Application.Current.MainWindow.Close();
                }
                else
                {
                    LoginMessage = $"The account was registered {Environment.NewLine} but never verified";
                    //Resend verification email?
                }
            }
            else
            {
                LoginMessage = $"Review username and password {Environment.NewLine} account was not found";
            }
        }
        /// <summary>
        /// Register command
        /// </summary>
        /// <param name="loginrequest"></param>
        public static void SendForgotEmail(ForgotPasswordRequest fprequest)
        {
            //serialized input
            string sinput = JsonSerializer.Serialize(fprequest);

            Task <HttpResponseMessage> response = APIHelper.ApiCall("Accounts/verify-email", HttpMethod.Post, sinput);

            //send output
        }
Exemple #3
0
        /// <summary>
        /// Register command
        /// </summary>
        /// <param name="loginrequest"></param>
        public void RegisterCom(RegisterRequest registerrequest)
        {
            //serialized input
            string sinput = JsonSerializer.Serialize(registerrequest);

            Task <HttpResponseMessage> loginresponse = APIHelper.ApiCall("Accounts/register", HttpMethod.Post, sinput);

            //Server error most like if caught - TODO in future
            HttpResponseMessage response = loginresponse.Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //Launch login page with message saying "Account successfully registered, sign in here" - TODO
            }
            else
            {
                SignUpMessage = $"This account already exists {Environment.NewLine} use the login screen";
            }
        }