예제 #1
0
        public IActionResult ConfirmEmail(EmailConfirmationRequest model)
        {
            if (string.IsNullOrEmpty(model.UserId) || model.UserId.Length < 2)
            {
                return(View("ConfirmEmailFail", null));
            }

            if (string.IsNullOrEmpty(model.Token) || model.Token.Length < 2)
            {
                return(View("ConfirmEmailFail", null));
            }

            var response = WebAPI <AuthenticationResult, EmailConfirmationRequest> .Consume(SharedEndpoints.ConfirmEmail, model, "");

            if (!response.IsSuccessful)
            {
                return(View("ConfirmEmailFail", response.DebugMessage));
            }

            return(View());
        }
예제 #2
0
        public JsonResult ProcessAddBasicInfo(UserRegistrationRequest model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.FullName) || model.FullName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid FullName" }, new JsonSerializerOptions
                    {
                        PropertyNameCaseInsensitive = false,
                    }));
                }

                if (string.IsNullOrEmpty(model.City) || model.City.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid City" }));
                }

                if (string.IsNullOrEmpty(model.PhoneNumber) || model.PhoneNumber.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid PhoneNumber" }));
                }

                if (string.IsNullOrEmpty(model.Salutation) || model.Salutation.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid Salutation" }));
                }

                //model.AdminUserId = userData.UserId;
                //model.Status = model.StatusVal ? 1 : 0;

                //if (Session["_AssignmentList_"] is List<AssignmentObj> previousAssignmentList)
                //{
                //    if (previousAssignmentList.Count(x => x.Name.ToLower().Trim().ToStandardHash() == model.Name.ToLower().Trim().ToStandardHash()) > 0)
                //        return Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Assignment Information  Already Exist!" });
                //}
                //var response = AssignmentService.AddAssignment(model, userData.Username);
                //if (response?.Status == null)
                //{
                //    return Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" });
                //}

                //Extract role from query string
                //var paramList = CompareApp.GetRequestInfo(_httpContextAccessor);
                //var role =paramList.Where(kvp => kvp.Value == "section").FirstOrDefault().Value ;
                // model.Role = role;

                string confirmLink = Url.Action("ConfirmEmail", "Home", new { userId = "{userId}", token = "{token}" }, Request.Scheme);
                model.ConfirmationLink = HttpUtility.UrlDecode(confirmLink);

                var response = WebAPI <AuthenticationResult, UserRegistrationRequest> .Consume(SharedEndpoints.Register, model, model.Email);

                if (!response.IsSuccessful)
                {
                    return(Json(new { IsSuccessful = false, IsReload = false, Error = response.DebugMessage }, new JsonSerializerOptions
                    {
                        PropertyNameCaseInsensitive = false,
                    }));
                }
                //add to coockie
                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" }, new JsonSerializerOptions
                {
                    PropertyNameCaseInsensitive = false,
                }));
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Debug, $"{ex.StackTrace} ==> {ex.Source}  ==> {ex.Message}");
                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "Process Error Occurred! Please try again later" }));
            }
        }