Ejemplo n.º 1
0
        public async Task <IActionResult> CreateUserAsync([FromBody] UserSignUp signUpModel)
        {
            IdentityResult result = null;

            try
            {
                ApplicationUser user = new ApplicationUser
                {
                    UserName = signUpModel.EmailAddress,
                    Email    = signUpModel.EmailAddress,
                };
                result = await _userManager.CreateAsync(user, signUpModel.Password);

                if (result.Succeeded)
                {
                    IdentityUser newUser = await _userManager.FindByEmailAsync(signUpModel.EmailAddress);

                    return(Json(new { success = true }));
                }
            }
            catch (Exception ex)
            {
                string exception = ex.ToString();
            }
            return(Json(new { success = false, responseText = result.Errors.FirstOrDefault().Description }));
        }
Ejemplo n.º 2
0
        public IActionResult SignUp(UserSignUp userSignUp)
        {
            if (ModelState.IsValid)
            {
                int userID = (int)_signUpSystemAPI.VerifyEmail(userSignUp.Email);


                if (userID != 0)
                {
                    ModelState.AddModelError(string.Empty, "Cette adresse Email est déjà utilisée.");
                    return(View());
                }
                else
                {
                    string publicKey = _controllerAPI.GetPublicKey();

                    userSignUp.Password = _cryptingRSA.Encrypt(userSignUp.Password, publicKey);

                    _controllerAPI.PostAPI("User/Register", userSignUp.User_WebToApi());
                    ViewBag.Message = "Merci pour votre inscription, Bienvenue!";
                    return(View("SignUpSuccess"));
                }
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
        public bool InitiateSignUpProcess(UserSignUp signupdetails)
        {
            try
            {
                bool isSignin = this._signUpDA.InitiateSignUpProcess(signupdetails);

                if (isSignin && signupdetails.UserType == 2)
                {
                    this._signInDA = new SignInDataAccess();
                    var objEmail = this._signInDA.GetEmailData("GET_PWD_CSR");
                    objEmail.Body = string.Format(objEmail.Body, signupdetails.FirstName);
                    EmailHelper.SendEmail(objEmail, signupdetails.EmailAddress);

                    objEmail      = this._signInDA.GetEmailData("GET_PWD_CSR_SMS");
                    objEmail.Body = string.Format(objEmail.Body, signupdetails.FirstName);
                    SMSHelper.SendSMS(objEmail, signupdetails.PhoneNumber);
                }
                return(isSignin);
            }
            catch (Exception ex)
            {
                //Log
                throw ex;
            }
            finally
            {
                //Log
            }
        }
Ejemplo n.º 4
0
        public ActionResult Index(UserSignUp SignUp)
        {
            if (ModelState.IsValid && SignUp.Condition == "true")
            {
                var userdb = db.Users.FirstOrDefault(f => f.UserName.ToUpper() == SignUp.UserName.ToUpper() || f.Mail == SignUp.Mail);
                if (userdb == null && SignUp.Password == SignUp.ConfirmPassword)
                {
                    UserDb user = new UserDb();

                    SignUp.ViewFromDb(user);

                    user.HashPassword = SHA.CustumSHA(SignUp.Password);
                    db.Users.Add(user);
                    db.SaveChanges();
                    var userCod = user.Id + 10000;
                    user.UserCod = user.Id.ToString() + userCod.ToString();
                    db.UserRoles.Add(new UserRole()
                    {
                        UserDbId = user.Id, RoleId = 1
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Login", "UserLogin"));
                }
                else
                {
                    ViewBag.faq = db.Faqs.FirstOrDefault(f => f.FaqTitle == "Sifaris Sertleri");
                    return(View(SignUp));
                }
            }
            ViewBag.faq = db.Faqs.FirstOrDefault(f => f.FaqTitle == "Sifaris Sertleri");
            return(View(SignUp));
        }
        public bool SignUp(UserSignUp uSU)
        {
            UserService uS = new UserService();


            return(uS.InsertUser(uSU));
        }
        public async Task <IActionResult> SaveProfileInfoChanges(UserSignUp userModel)
        {
            if (userModel.Username == "" || userModel.Username == null)
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            if (userModel.Email == "" || userModel.Email == null)
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            if (userModel.Name == "" || userModel.Name == null)
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            if (userModel.Surname == "" || userModel.Surname == null)
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            if (userModel.Address == "" || userModel.Address == null)
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            var user = await _userManager.FindByEmailAsync(userModel.Email);

            if (user != null)
            {
                user.UserName    = userModel.Username;
                user.PhoneNumber = userModel.PhoneNumber;
                user.Address     = userModel.Address;
                user.Name        = userModel.Name;
                user.Surname     = userModel.Surname;
                if (userModel.NewPassword.Length >= 6)
                {
                    if (await _userManager.CheckPasswordAsync(user, userModel.Password))
                    {
                        if (userModel.NewPassword == userModel.ConfirmPassword)
                        {
                            var result = await _userManager.ChangePasswordAsync(user, userModel.Password, userModel.NewPassword);
                        }
                        else
                        {
                            return(BadRequest(new { message = "Passwords are mismatched." }));
                        }
                    }
                    else
                    {
                        return(BadRequest(new { message = "Password is incorrect." }));
                    }
                }

                _context.Entry((User)user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Ok(new { message = "Successfully changed." }));
            }
            else
            {
                return(BadRequest());
            }
        }
        // POST: api/<controller>/Login
        public async Task <IActionResult> SaveFirstLoginChanges(UserSignUp model)
        {
            var user = _context.Users.Where(x => x.Id == model.UserId).ToList().First();


            if (model.NewPassword.Length >= 6)
            {
                if (await _userManager.CheckPasswordAsync(user, model.Password))
                {
                    if (model.NewPassword == model.ConfirmPassword)
                    {
                        var result = await _userManager.ChangePasswordAsync(user, model.Password, model.NewPassword);

                        user.isConfirmed = true;
                        _context.Entry((User)user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        await _context.SaveChangesAsync();

                        return(Ok(new { message = "Successfully changed." }));
                    }
                    else
                    {
                        return(BadRequest(new { message = "Passwords are mismatched." }));
                    }
                }
                else
                {
                    return(BadRequest(new { message = "Password is incorrect." }));
                }
            }

            return(BadRequest(new { message = "Password is too short, needs at least 6 characters!" }));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Signs up a user in the application
        /// </summary>
        /// <param name="user">The info to signs up a user</param>
        /// See <see cref="Areas.Identity.Models.UserSignUp"/> to know the param structure
        /// <returns>The IActionResult of the signup action</returns>
        public IActionResult signUp([FromBody] UserSignUp user)
        {
            var userExists = _context.User.Where(u => u.email == user.email);

            if (userExists.Count() != 0)
            {
                if (userExists.First().dateDeleted != null)
                {
                    return(BadRequest(new { error = "DeleteRequested" }));
                }

                return(BadRequest(new { error = "EmailAlreadyExistsError" }));
            }

            User newUser = new User {
                email           = user.email,
                nickname        = user.username,
                password        = PasswordHasher.hashPassword(user.password),
                tokenValidation = (user.password == null) ? null : Guid.NewGuid().ToString("N"),
                role            = RoleManager.getNormalUser(_context)
            };


            try {
                _context.User.Add(newUser);
                _context.SaveChanges();

                Home.Util.GroupNew.launch(newUser, null, null, Home.Models.TypeGroupNew.WELCOME, false, _context);
                EmailSender.sendVerificationToken(newUser.email, newUser.nickname, newUser.tokenValidation);
            } catch (Exception) {
                return(StatusCode(500));
            }

            return(Ok());
        }
Ejemplo n.º 9
0
 public IActionResult SignUp(UserSignUp registration)
 {
     try
     {
         ResponseData data    = userBL.SignUp(registration);
         bool         success = false;
         string       message;
         if (data == null)
         {
             message = "Email already exist";
             return(NotFound(new { success, message }));
         }
         else
         {
             success = true;
             message = "Account Created Successfully";
             string messageSender = "SignUp successful with" + "\n Name : " + Convert.ToString(registration.FirstName) + "\n Email : " + Convert.ToString(registration.EmailAddress) +
                                    "\n Password : " + Convert.ToString(registration.Password);
             sender.Message(messageSender);
             return(Ok(new { success, message, data }));
         }
     }
     catch (Exception e)
     {
         bool   success = false;
         string message = e.Message;
         return(BadRequest(new { success, message }));
     }
 }
Ejemplo n.º 10
0
        public async Task <IActionResult> SignUp([FromBody] UserSignUp newU)
        {
            if (String.IsNullOrEmpty(newU.Name))
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Thiếu họ tên người dùng" }));
            }
            if (String.IsNullOrEmpty(newU.Username) || String.IsNullOrEmpty(newU.Password))
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Thiếu tên đăng nhập hoặc mật khẩu" }));
            }
            if (String.IsNullOrEmpty(newU.Password) || String.IsNullOrEmpty(newU.Password))
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Mật khẩu không được để trống" }));
            }
            if (newU.Password.Length < 6)
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Mật khẩu không được ngắn hơn 6 kí tự" }));
            }

            if (!newU.Password.Equals(newU.Password_confirm))
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Xác nhận mật khẩu không khớp" }));
            }
            var tmp1 = await _iUserRepository.FindByEmail(newU.Email);

            if (tmp1 != null)
            {
                return(Ok(new { status = ResultStatus.STATUS_DUPLICATE, message = "Email đã có người đăng kí" }));
            }
            var tmp2 = await _iUserRepository.FindByUsername(newU.Username);

            if (tmp2 != null)
            {
                return(Ok(new { status = ResultStatus.STATUS_DUPLICATE, message = "Username đã có người đăng kí" }));
            }
            if (newU.Role.Equals(RoleCode.ROLE_ADMIN))
            {
                return(Ok(new { status = ResultStatus.STATUS_FOBIDDEN, message = "Không thể tạo tài khoản mang quyền Admin" }));
            }
            var role = await roleRepository.FindRoleById(newU.Role);

            if (role == null)
            {
                return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Không tìm thấy quyền" }));
            }
            var user = new User
            {
                name     = newU.Name,
                username = newU.Username,
                email    = newU.Email,
                password = newU.Password,
                IsLocked = 0,
                Role     = role
            };

            await _iUserRepository.Create(user);

            return(Ok(new { status = 1, data = user }));
        }
Ejemplo n.º 11
0
        public ActionResult SignUp(UserSignUp signUp)
        {
            var builder = new UserBuildercs();
            var code    = builder.SignUp(signUp);
            var user    = builder.GetUser(code);

            return(RedirectToAction("Index", "Shop"));
        }
        /// <summary>
        /// This method is used to register a new user in the database.
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="Password"></param>
        /// <param name="EmailId"></param>
        /// <returns></returns>

        public static string CreateUser(string UserId, string Password, string EmailId)
        {
            UserSignUp us = new UserSignUp();

            us.UserId   = UserId;
            us.Password = Password;
            us.EmailId  = EmailId;
            return(DataProvider.Registration(us));
        }
        public async Task <ActionResult> SignUp([FromBody] UserSignUp model)
        {
            var user = _mapper.Map <UserSignUp, User>(model);

            var userCreate = await _userManager.CreateAsync(user, model.Password);

            return(userCreate.Succeeded ? Created(string.Empty, string.Empty) :
                   Problem(userCreate.Errors.First().Description, null, 500));
        }
Ejemplo n.º 14
0
        public void SignUp(UserSignUp entitie)
        {
            if (_UserRepository.IsEmailRegistered(entitie.Email))
            {
                throw new Exception("Este email ya se encuentra registrado");
            }

            _UserRepository.AddUser(entitie);
        }
Ejemplo n.º 15
0
        private void Handle(UserSignUp message)
        {
            var newUser = new UserQuery();

            newUser.UserName = message.UserName;
            newUser.Password = message.Password;
            newUser.RebellionBoosterPacks = 5;
            newUser.Id = message.Id;
            model.Users.Add(newUser);
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> SignUp([FromBody] UserSignUp dto)
        {
            var userCreateResult = await _ctx.CreateUser(dto);

            if (userCreateResult.Succeeded)
            {
                return(Created(string.Empty, string.Empty));
            }

            return(Problem(userCreateResult.Errors.First().Description, null, 500));
        }
Ejemplo n.º 17
0
        public UserSignUp SignUp(UserSignUp user)
        {
            RestRequest request = new RestRequest()
            {
                Method = Method.POST
            };

            request.AddJsonBody(user);

            return(Get <UserSignUp>(request));
        }
Ejemplo n.º 18
0
 public ResponseData SignUp(UserSignUp registration)
 {
     try
     {
         ResponseData data = userRL.SignUp(registration);
         return(data);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public async Task <SignUpResponse> SignUpUser(UserSignUp userSignUp)
 {
     try
     {
         return(await fitApi.UserSignUpAsync(userSignUp));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         throw;
     }
 }
Ejemplo n.º 20
0
        public async Task <IdentityResult> CreateUser(UserSignUp dto)
        {
            var user = new User()
            {
                FullName    = dto.FullName,
                UserName    = dto.FullName,
                PhoneNumber = dto.PhoneNumber,
                Email       = dto.Email
            };

            return(await _userManager.CreateAsync(user, dto.Password));
        }
Ejemplo n.º 21
0
 public ActionResult SignUp(UserSignUp entitie)
 {
     try
     {
         _userProcessor.SignUp(entitie);
     }
     catch (Exception ex)
     {
         return(View("Error", ex));
     }
     return(View("SignIn"));
 }
        // POST: api/UserSignUp
        public User Post([FromBody] UserSignUp userSignUp)
        {
            udc = new UserDbConnection();

            if (userSignUp.Username != null && userSignUp.Password != null && userSignUp.PasswordConfirmation == userSignUp.Password)
            {
                udc.InsertUser(userSignUp.Username, SHA.GenerateSHA256String(userSignUp.Password));
            }

            User user = udc.GetUser(userSignUp.Username, SHA.GenerateSHA256String(userSignUp.Password));

            return(user);
        }
Ejemplo n.º 23
0
 private void buttonSignUp_Click(object sender, EventArgs e)
 {
     UserSignUp = new UserSignUp();
     UserSignUp.Attach(this);
     if (ValidateUserInfo(GetUserModel()))
     {
         SignUp(GetUserModel());
     }
     else
     {
         MessageBox.Show("لطفا همه مقادیر را وارد نمایید");
     }
 }
Ejemplo n.º 24
0
        public void Post([FromBody] UserSignUp value)
        {
            var userManager = serviceProvider.GetRequiredService <UserManager <AplicationUser> >();

            AplicationUser user = new AplicationUser()
            {
                Email         = value.email,
                SecurityStamp = Guid.NewGuid().ToString(),
                UserName      = value.username
            };

            userManager.CreateAsync(user, value.password);
        }
Ejemplo n.º 25
0
        public async Task <string> SignUpAdmin(UserSignUp cred)
        {
            User user = new User()
            {
                Email = cred.Email, FirstName = cred.FirstName, LastName = cred.LastName, UserName = cred.UserName
            };
            var result = await _userManager.CreateAsync(user, cred.Password);

            await _userManager.AddToRoleAsync(user, "AdminUser");

            //add to roles here
            return(result.ToString());
        }
        /// <summary>
        /// Converts UserSignUpModel to UserSignUp.
        /// </summary>
        /// <param name="uSUModel"></param>
        /// <returns></returns>
        public UserSignUp ConvertFromUserSignUpModelToSignUp(UserSignUpModel uSUModel)
        {
            UserSignUp uSU = new UserSignUp
            {
                UserName = uSUModel.UserName,
                Email    = uSUModel.Email,
                Phone    = uSUModel.Phone,
                ZipCode  = uSUModel.ZipCode,
                Region   = uSUModel.Region,
                Password = uSUModel.Password
            };

            return(uSU);
        }
Ejemplo n.º 27
0
        public async Task <ActionResult> SaveSignUpDetails(UserSignUp userdetails)
        {
            //var SignUpObj = _Kernel.Get<ISignUp>();

            //Patient
            //userdetails.UserType = 1;
            //CSR
            //userdetails.UserType = 3;

            //userdetails.Active = 1;



            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var json                = JsonConvert.SerializeObject(userdetails);
                var content             = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage Res = await client.PostAsync("api/SignUpAPI/PostUserSignUp", content);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var SignInResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    //UserInfo = JsonConvert.DeserializeObject<List<User>>(SignInResponse);
                    //if (Convert.ToBoolean(SignInResponse))
                    return(View("SignUpSuccessfull"));
                    //else
                    //  return View("LoginFailure");
                }
                else
                {
                    var SignInResponse = Res.Content.ReadAsStringAsync().Result;
                    ViewData["ErrorMessage"] = SignInResponse.ToString();
                    return(View("SignUpFailure"));
                }
                //return View("Index");
                //return View("LoginFailure");
            }
        }
Ejemplo n.º 28
0
        public async Task <Object> GetUserProfileInfo()
        {
            string UserId = User.Claims.First().Value;
            var    user   = await _userManager.FindByIdAsync(UserId);

            UserSignUp userinfo = new UserSignUp();

            userinfo.PhoneNumber = user.PhoneNumber;
            userinfo.Surname     = user.Surname;
            userinfo.Username    = user.UserName;
            userinfo.Name        = user.Name;
            userinfo.Email       = user.Email;
            userinfo.Address     = user.Address;
            userinfo.isConfirmed = user.isConfirmed;
            return(Ok(new { userinfo }));
        }
Ejemplo n.º 29
0
        public async Task <ActionResult <ResponseMessage <string> > > SignUp(UserSignUp userSignUp)
        {
            var user = _mapper.Map <UserSignUp, User>(userSignUp);

            var userCreateResult = await _userManager.CreateAsync(user, userSignUp.Password);

            if (userCreateResult.Succeeded)
            {
                return(Ok(new ResponseMessage <string> {
                    Message = "User was created"
                }));
            }
            return(BadRequest(new ResponseMessage <string> {
                Message = "Error creating user"
            }));
        }
Ejemplo n.º 30
0
        public ActionResult SignUp(FormCollection frm)
        {
            UserSignUp ToConfirm = new UserSignUp();

            ToConfirm.TermAndConditions = Convert.ToBoolean(frm.Get("TermAndConditions"));

            string ViewPassword      = frm.Get("Password");
            string ViewPasswordAgain = frm.Get("PasswordAgain");

            string   ViewName    = frm.Get("Name");
            string   ViewSurname = frm.Get("Surname");
            string   ViewMail    = frm.Get("EMail");
            BaseUser ToAdd       = new BaseUser();

            ToAdd.Authority   = "UnConfirmed";
            ToAdd.EMail       = ViewMail;
            ToAdd.Name        = ViewName;
            ToAdd.Password    = ViewPassword;
            ToAdd.Surname     = ViewSurname;
            ToConfirm.Name    = ViewName;
            ToConfirm.Surname = ViewSurname;
            ToConfirm.EMail   = ViewMail;


            if (ViewPassword != ViewPasswordAgain)

            {
                ViewBag.Mesaj = "Şifreleriniz Uyuşmuyor";
                return(View(ToConfirm));
            }

            if (!ToConfirm.TermAndConditions)
            {
                ViewBag.Mesaj = "Sisteme Kayıt Olabilmeniz İçin Kullanıcı Sözleşmesini Onaylamanız Gerekir";
                return(View(ToConfirm));
            }
            _db.Users.Add(ToAdd);
            if (_db.SaveChanges() > 0)
            {
                return(RedirectToAction("SuccessPage", "Home"));
            }
            else
            {
                ViewBag.Mesaj = "Veritabanı Bağlantısı Sırasında Bir Hata Oluştu";
            }
            return(View(ToConfirm));
        }