Пример #1
0
        public ActionResult <SendOtpModel> SendOtp([FromForm] SendOtpModel sendOtpModel)
        {
            string jwtToken = new UserDataAccess().SendOtpForPassReset(sendOtpModel.Otp, sendOtpModel.Email);

            if (jwtToken == "Email Not Verified")
            {
                return(Unauthorized(new CustomResponseModel()
                {
                    Code = "401", Phrase = "Unauthorized", Message = jwtToken
                }));
            }
            else if (jwtToken == "Email Not Found")
            {
                return(NotFound(new CustomResponseModel()
                {
                    Code = "404", Phrase = "NotFound", Message = jwtToken
                }));
            }
            else if (jwtToken != "")
            {
                return(Ok(new { message = "OTP Sent", token = jwtToken }));
            }
            return(Unauthorized(new CustomResponseModel()
            {
                Code = "401", Phrase = "Unauthorized", Message = "Unauthorized"
            }));
        }
Пример #2
0
        async Task SendOtpEmail()
        {
            try
            {
                string json                  = "{ Email: '" + Email + "'}";
                var    requestBody           = new StringContent(json, Encoding.UTF8, "application/json");
                var    client                = new HttpClient();
                HttpResponseMessage response = await client.PostAsync("http://192.168.1.34:5000/api/auth/sendotp", requestBody);

                //response.EnsureSuccessStatusCode();
                string responseBody = await response.Content.ReadAsStringAsync();

                SendOtpModel otpModel = JsonConvert.DeserializeObject <SendOtpModel>(responseBody);
                await SecureStorage.SetAsync("otp", otpModel.Otp);

                await SecureStorage.SetAsync("ref", otpModel.Ref);

                Preferences.Set("otpemail", otpModel.Email);
                Reference = await SecureStorage.GetAsync("ref");
            }
            catch (Exception ex)
            {
            }
        }