示例#1
0
        public UserDetails GetUserDetails(string userName, string password)
        {
            bool        IsDone = false;
            UserDetails cust   = new UserDetails();

            if (IsLoggedUserPresent(userName, password))
            {
                if (IsLogInUserVerified(userName, password))
                {
                    IsDone = true;
                }
            }

            if (IsDone)
            {
                LoginOperations loginOp = new LoginOperations();
                var             result  = loginOp.GetUserDetails(userName, password);

                cust.Id          = result.Id;
                cust.UserName    = result.UserName;
                cust.UserType    = result.UserType;
                cust.IsVerified  = result.IsVerified;
                cust.CreateDate  = result.CreateDate;
                cust.UpdatedDate = result.UpdatedDate;
            }

            return(cust);
        }
        public HttpResponseMessage GetUserDetails(string userName, string password)
        {
            bool IsDone             = false;
            List <UserDetails> user = new List <UserDetails>();
            UserDetails        cust = new UserDetails();

            if (CheckIfUserExist(userName, password))
            {
                if (CheckIfUserAuthenticated(userName, password))
                {
                    IsDone = true;
                }
            }

            if (IsDone)
            {
                LoginOperations loginOp = new LoginOperations();
                var             result  = loginOp.GetUserDetails(userName, password);

                cust.Id          = result.Id;
                cust.UserName    = result.UserName;
                cust.UserType    = result.UserType;
                cust.IsVerified  = result.IsVerified;
                cust.CreateDate  = result.CreateDate;
                cust.UpdatedDate = result.UpdatedDate;
            }
            else
            {
                user.Add(cust);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(user)));
        }
示例#3
0
        public ActionResult ValidateAccount(UIAccount_V uim)
        {
            AjaxStatus status = new AjaxStatus();

            using (var context = new DataContext())
            {
                try
                {
                    Account dbm = LoginOperations.TryRead(Account.EMPTY_ACCOUNT, context, uim.email);
                    dbm = LoginOperations.TryValidate(dbm, context, uim.password);
                    if (dbm == null)
                    {
                        status.SetError("Felaktig användare eller lösenord");
                    }
                    else
                    {
                        SetLoginAccount(dbm);
                        status.nextURL = "/Home";
                    }
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    base.HandleException("ValidateAccount", e);
                    status.SetError(e.Message);
                }
            }
            return(Json(status));
        }
示例#4
0
        /* Render */

        public ActionResult Index()
        {
            if (!LoginOperations.CanRender(Account.EMPTY_ACCOUNT))
            {
                return(base.ToLoginPage());
            }
            return(View());
        }
        public bool CheckIfUserAuthenticated(string userName, string password)
        {
            bool            IsUserAuthenticated = false;
            LoginOperations loginOp             = new LoginOperations();

            IsUserAuthenticated = loginOp.IsLogInUserVerified(userName, password);

            return(IsUserAuthenticated);
        }
        public bool CheckIfUserExist(string userName, string password)
        {
            bool            IsUserExist = false;
            LoginOperations loginOp     = new LoginOperations();

            IsUserExist = loginOp.IsLoggedUserPresent(userName, password);

            return(IsUserExist);
        }
        public static void completeRegister(MainWindow main)
        {
            using (PMSContext context = new PMSContext())
            {
                TblUsers myUser = new TblUsers();
                myUser.Firstname = main.txtFirstName.Text;
                myUser.Lastname  = main.txtLastName.Text;
                if (main.txtPw1.Password.ToString() != main.txtPw2.Password.ToString())
                {
                    MessageBox.Show("Error! Entered passwords are not matching. Please re-type your password!");
                    return;
                }
                Guid obj = Guid.NewGuid();
                myUser.SaltOfPw = obj.ToString();
                myUser.UserPw   = GlobalMethods.returnUserPw(main.txtPw1.Password.ToString(), myUser.SaltOfPw);


                if (main.cmbBoxUserRank.SelectedIndex < 1)
                {
                    MessageBox.Show("Error! Please select your user rank / role first!");
                    return;
                }
                myUser.UserType   = (main.cmbBoxUserRank.SelectedItem as TblUserTypes).UserTypeId;
                myUser.UserEmail  = main.txtEmail.Text;
                myUser.RegisterIp = GlobalMethods.returnUserIp();
                try
                {
                    context.TblUsers.Add(myUser);
                    context.SaveChanges();
                }
                catch (Exception E)
                {
                    MessageBox.Show("An error has occured while registering. Error is: \n" + E.Message.ToString() + "\n\n" + E?.InnerException?.Message);
                    return;
                }

                MessageBox.Show("User has been succcesfully registered");
                //do the after register operations

                main.txtLoginEmail.Text        = main.txtEmail.Text;
                main.txtLoginPassword.Password = main.txtPw1.Password;
                main.txtEmail.Text             = "";
                main.txtFirstName.Text         = "";
                main.txtLastName.Text          = "";
                main.txtPw1.Password           = "";
                main.txtPw2.Password           = "";

                LoginOperations.loginTry(main);
            }
        }
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (tabDrugs.IsSelected)
         {
             LoggedInOperations.refreshDrugsDataGrid();
         }
         if (tabLogin.IsSelected)
         {
             LoginOperations.loginTry(this);
         }
         if (tabRegister.IsSelected)
         {
             RegisterOperations.completeRegister(this);
         }
     }
 }
示例#9
0
        public ActionResult Index(ReshimgathiMatrimony.Models.Login model)
        {
            throw new Exception("Manual exception thrown.");
            if (ModelState.IsValid)
            {
                LoginOperations loginOp     = new LoginOperations();
                bool            loginStatus = loginOp.IsLoggedUserPresent(model.UserName, model.Password);

                if (loginStatus)
                {
                    bool IsVerified = loginOp.IsLogInUserVerified(model.UserName, model.Password);
                    if (IsVerified)
                    {
                        UserType type        = loginOp.LoggedUserType(model.UserName, model.Password);
                        var      userDetails = loginOp.GetUserDetails(model.UserName, model.Password);
                        UserLoginId  = userDetails.Id;
                        BaseUserType = userDetails.UserType;
                        SetSession();

                        if (type == UserType.User)
                        {
                            return(RedirectToAction("Index", "Dashboard"));
                        }
                        else
                        {
                            //Admin user goes here.
                            return(RedirectToAction("Index", "Admin"));
                        }
                    }
                    else
                    {
                        //User is not verified. He/she needs to verify account by his/her email address or Phone number.
                        ModelState.AddModelError(string.Empty, "Logging user is not verified either by Email address or Phone number. Please verify the user.");
                    }
                }
                else
                {
                    //default Index Get view with ErrorMessage. Username and password are wrong.
                    ModelState.AddModelError(string.Empty, "Username or password are not correct. Please try again with the correct details.");
                }
            }

            return(View(model));
        }
示例#10
0
        public ActionResult Login(Salon1.Models.LoginViewModel login)
        {
            LoginOperations loginoperation = new LoginOperations();
            var             isvalid        = loginoperation.Login(login);

            if (!isvalid)
            {
                ModelState.AddModelError("fgfg", "Invalid username or password");

                return(View("Index", login));
            }
            else
            {
                Session["UserName"] = login.LoginName;
                var user = loginoperation.GetUserByName(login.LoginName);
                Session["UserType"] = user.User.UserType;
                return(RedirectToAction("Index", "Home"));
            }
        }
示例#11
0
        public ActionResult ForgotAccount(UIAccount_F uim)
        {
            AjaxStatus status = new AjaxStatus();

            using (var context = new DataContext())
            {
                try
                {
                    Account dbm       = uim.CreateModel();
                    Account requester = LoginOperations.TryRead(Account.EMPTY_ACCOUNT, context, dbm.email);
                    LoginOperations.TrySendPIN(requester, context, Account.EMPTY_ACCOUNT);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    base.HandleException("ForgotAccount", e);
                    status.SetError(e.Message);
                }
            }
            return(Json(status));
        }
 private void btnLogout_Click(object sender, RoutedEventArgs e)
 {
     LoginOperations.tryLogout();
 }
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     LoginOperations.loginTry(this);
 }
 public HomeController(ILogger <HomeController> logger)
 {
     _logger            = logger;
     registerOperations = new RegisterOperations();
     loginOperations    = new LoginOperations();
 }
示例#15
0
        public UserType LoggedUserType(string userName, string Password)
        {
            LoginOperations loginOp = new LoginOperations();

            return(loginOp.LoggedUserType(userName, Password));
        }