public HttpResponseMessage ChangePassword(HttpRequestMessage request, [FromBody] AccountChangePasswordModel passwordModel)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                var loginName = User.Identity.Name;
                passwordModel.LoginID = loginName;
                ValidateAuthorizedUser(passwordModel.LoginID);
                _SecurityAdapter.Initialize();
                //_SecurityAdapter.LogOut();

                bool success = _SecurityAdapter.ChangePassword(passwordModel.LoginID, passwordModel.OldPassword, passwordModel.NewPassword);
                //bool success = _SecurityAdapter.ChangePassword(loginName, passwordModel.OldPassword, passwordModel.NewPassword);
                if (success)
                {
                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to change password.");
                }
                //_SecurityAdapter.LogOut();
                return response;
            }));
        }
Example #2
0
        //[ValidateAntiForgeryToken]
        public ActionResult Login(AccountLoginModel viewModel)
        {
            _SecurityAdapter.Initialize();

            // Ensure we have a valid viewModel to work with
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            // Verify if a user exists with the provided identity information
            var exist = _SecurityAdapter.UserExists(viewModel.LoginID);

            // If a user was found
            if (exist)
            {
                // Then create an identity for it and sign it in
                var success = _SecurityAdapter.Login(viewModel.LoginID, viewModel.Password, viewModel.RememberMe);

                if (success)
                {
                    // If the user came from a specific page, redirect back to it
                    return(RedirectToLocal(viewModel.ReturnUrl));
                }
            }

            // No existing user was found that matched the given criteria
            ModelState.AddModelError("", "Invalid username or password.");

            // If we got this far, something failed, redisplay form
            return(View(viewModel));
        }
        public ActionResult Login(string returnUrl)
        {
            _SecurityAdapter.Initialize();

            return(View(new AccountLoginModel()
            {
                ReturnUrl = returnUrl
            }));
        }
        public HttpResponseMessage UpdateUser(HttpRequestMessage request, [FromBody] User userModel)
        {
            return(GetHttpResponse(request, () =>
            {
                User user = null;

                if (userModel.UserId == 0)
                {
                    _SecurityAdapter.Initialize();

                    _SecurityAdapter.Register(userModel.LoginID, "P@ssword",
                                              propertyValues: new
                    {
                        FirstName = userModel.FirstName,
                        LastName = userModel.LastName,
                        LoginId = userModel.LoginID,
                        EntityScope = userModel.EntityScope,
                        ScopeCode = userModel.ScopeCode,
                        GroupId = userModel.GroupId,
                        EmployeeCode = userModel.EmployeeCode,
                        Email = userModel.Email,
                        Mobile = userModel.Mobile,
                        LastLoginDate = DateTime.Now,
                        IsLock = false,
                        Deleted = false,
                        Active = true,
                        CreatedBy = "Auto",
                        CreatedOn = DateTime.Now,
                        UpdatedBy = "Auto",
                        UpdatedOn = DateTime.Now,
                    });

                    user = _CoreService.GetUserByLogin(userModel.LoginID);
                }
                else
                {
                    user = _CoreService.UpdateUser(userModel);
                }

                return request.CreateResponse <User>(HttpStatusCode.OK, user);
            }));
        }
        public HttpResponseMessage Login(HttpRequestMessage request, [FromBody] AccountLoginModel accountModel)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                _SecurityAdapter.Initialize();

                bool success = _SecurityAdapter.Login(accountModel.LoginEmail, accountModel.Password, accountModel.RememberMe);

                if (success)
                {
                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Unauthorized login attempt.");
                }

                return response;
            }));
        }
Example #6
0
        public ActionResult Register()
        {
            _SecurityAdapter.Initialize();

            return(View());
        }
Example #7
0
 [Route("login")]// acount/login
 public ActionResult Login()
 {
     _SecurityAdapter.Initialize();
     return(View());
 }