예제 #1
0
 public IActionResult Register(ValidateUser user)
 {
     if (ModelState.IsValid)
     {
         PasswordHasher <ValidateUser> Hasher = new PasswordHasher <ValidateUser>();
         user.password = Hasher.HashPassword(user, user.password);
         User thisUser = new User {
             first_name = user.first_name,
             last_name  = user.last_name,
             email      = user.email,
             password   = user.password
         };
         _context.Add(thisUser);
         _context.SaveChanges();
         HttpContext.Session.SetInt32("UserId", thisUser.UserId);
         return(RedirectToAction("Success", thisUser.UserId));
     }
     else
     {
         return(View("Index"));
     }
 }
        public void CanValidateByEmailAndUserNameWithValidPassWord(string username, string email)
        {
            var postString  = _fixture.AuthenticationUrl + "/api/Users/";
            var requestPost = new PostModelAuthentication
            {
                userName     = Helpers.RandomNameGenerator.RandomString(25),
                emailAddress = Helpers.RandomNameGenerator.RandomEmail(),
                active       = true,
                passWord     = "******"
            };

            var response =
                _fixture.BaseApiClient.GenericPostObject <PostModelResponse>(postString, requestPost).Result as
                PostModelResponse;

            Assert.Equal(201, response.StatusCode);
            if (username != null)
            {
                username = requestPost.userName.ToLowerInvariant();
            }

            if (email != null)
            {
                email = requestPost.emailAddress;
            }
            var requeststring   = _fixture.AuthenticationUrl + "/api/Validate/";
            var requestValidate = new ValidateUser
            {
                emailAddress = email,
                userName     = username,
                passWord     = requestPost.passWord
            };

            var resp = _fixture.AuthenicationApi.PostAValidation(requeststring, requestValidate).Result as ValidatePostResult;

            Assert.Equal(200, resp.StatusCode);
            Assert.True(resp.Valid);
        }
예제 #3
0
 private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string username      = ValidateUser.ValidateUsername(tbUsername.Text);
         string password      = ValidateUser.ValidateNewPassword(pbPassword.Password);
         string passwordAgain = pbPasswordAgain.Password;
         if (password == passwordAgain)
         {
             if (Authentification.NewUser(username, pbPassword.Password, comboBoxRoles.Text))
             {
                 DialogHelper.ShowInfo("Uživatel úspěšně přidán.");
                 this.Close();
             }
             else
             {
                 throw new NotImplementedException();
             }
         }
         else
         {
             DialogHelper.ShowWarning("Hesla se neshodují");
             pbPasswordAgain.Password = string.Empty;
         }
     }
     catch (InvalidUsernameException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch (InvalidAuthPasswordException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch
     {
         DialogHelper.ShowError("Uživatel nemohl být přidán.");
     }
 }
예제 #4
0
        public IHttpActionResult RemoveFitnessProgramFromUser(string userId, int fitnessProgramId)
        {
            var user    = this.usersService.GetById(userId);
            var isValid = ValidateUser.IsUsersValid(user.UserName, this.User.Identity.Name);

            if (!isValid)
            {
                return(this.BadRequest(MessageConstants.InvalidUser));
            }

            var fitnessProgram = this.fitnessProgramsService
                                 .GetById(fitnessProgramId)
                                 .FirstOrDefault();

            if (fitnessProgram == null)
            {
                return(this.BadRequest(string.Format(MessageConstants.FitnessProgramWithIdDoesNotExists, fitnessProgramId)));
            }

            var userDeletedProgram = this.usersService.RemoveFitnessProgramFromUserPrograms(user, fitnessProgram);

            return(this.Ok(Mapper.Map <UserResponseModel>(userDeletedProgram)));
        }
예제 #5
0
 public IActionResult Create(ValidateUser user)
 {
     if (ModelState.IsValid)
     {
         PasswordHasher <ValidateUser> Hasher = new PasswordHasher <ValidateUser>();
         user.Password = Hasher.HashPassword(user, user.Password);
         User newUser = new User
         {
             FirstName = user.FirstName,
             LastName  = user.LastName,
             Email     = user.Email,
             Password  = user.Password
         };
         _context.Add(newUser);
         _context.SaveChanges();
         HttpContext.Session.SetInt32("user_id", newUser.Id);
         return(RedirectToAction("Home"));
     }
     else
     {
         return(View("Index"));
     }
 }
예제 #6
0
        public async Task <IActionResult> Registrate(ValidateUser user)
        {
            if (ModelState.IsValid)
            {
                User newUser = new User {
                    UserName = user.Email, Email = user.Email
                };

                IdentityResult result = await _userManager.CreateAsync(newUser, user.Password);

                if (result.Succeeded)
                {
                    // This will create a student automatically
                    await _userManager.AddToRoleAsync(newUser, "Student");

                    await _signInManager.SignInAsync(newUser, isPersistent : false);
                }
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View("Register"));
            }
        }
예제 #7
0
        public async Task <IActionResult> SignIn(SignInFormModel input, [FromServices] ValidateUser useCaseValidateUser)
        {
            if (!ModelState.IsValid)
            {
                return(View(new SignInViewModel
                {
                    ReturnUrl = input.ReturnUrl,
                }));
            }

            var results = await useCaseValidateUser.ExecuteAsync(input);

            if (results.Any())
            {
                foreach (var error in results)
                {
                    ModelState.AddModelError(error.Key, error.Message);
                }
                return(View(new SignInViewModel
                {
                    ReturnUrl = input.ReturnUrl,
                }));
            }

            var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);

            identity.AddClaims(new[]
            {
                new Claim(ClaimTypes.Name, _securityConfig.User),
                new Claim(ClaimTypes.NameIdentifier, _securityConfig.User)
            });

            await HttpContext.SignInAsync(new ClaimsPrincipal(identity));

            return(Redirect(input.ReturnUrl));
        }
예제 #8
0
        private async void SubmitButton_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(userNameEntry.Text) || string.IsNullOrWhiteSpace(passwordEntry.Text))
            {
                await DisplayAlert("Log In", "Enter Login and Password", "OK");
            }
            else
            {
                IvalidateUser validator = new ValidateUser();

                bool result = await validator.AuthenticationUser(userNameEntry.Text, passwordEntry.Text);

                if (result)
                {
                    await DisplayAlert("Log In", "Login is successful", "OK");

                    await Navigation.PushAsync(new UsersViewPage());
                }
                else
                {
                    await DisplayAlert("Log In", "Login or password is incorected", "OK");
                }
            }
        }
예제 #9
0
 public UserRepo(SarahaContext context, ValidateUser validateUser)
 {
     _context      = context;
     _validateUser = validateUser;
 }
예제 #10
0
        public string SendMT(string xmlreq)
        {
            logger.Info("xmlreq befor:" + xmlreq);
            xmlreq = Server.HtmlDecode(xmlreq);
            logger.Info("xmlreq after:" + xmlreq);
            SMSRS response = new SMSRS();

            try
            {
                SMSRQ request = ConvertXML.XMLToModel <SMSRQ>(xmlreq);
                response.HEADER = new HEADERRES()
                {
                    DEST      = request.HEADER.DEST,
                    PWD       = request.HEADER.PWD,
                    SOURCE    = request.HEADER.SOURCE,
                    TRANSID   = request.HEADER.TRANSID,
                    TRANSTIME = request.HEADER.TRANSTIME,
                    USER      = request.HEADER.USER,
                };
                if (ValidateUser.CheckUser(request.HEADER.USER, request.HEADER.PWD))
                {
                    DateTime             transTime = DateTime.ParseExact(request.HEADER.TRANSTIME, "yyyyMMddHHmmss", null);
                    QueueServiceProvider provider  = new QueueServiceProvider();
                    EncryptAndDecrypt    ead       = new EncryptAndDecrypt();
                    foreach (var item in request.DATA.SMS)
                    {
                        QueueService model = new QueueService()
                        {
                            Content        = item.CONTENT,
                            Dest           = request.HEADER.DEST,
                            Password       = request.HEADER.PWD,
                            Priority       = item.PRIORITY,
                            ProcessingCode = item.PROCESSINGCODE,
                            Receiver       = item.RECEIVER,
                            Source         = request.HEADER.SOURCE,
                            TransID        = request.HEADER.TRANSID,
                            TransTime      = transTime,
                            DateCreate     = DateTime.Now,
                            User           = request.HEADER.USER,
                            SMSID          = item.SMSID
                        };
                        provider.Insert(model);
                    }
                    response.DATA = new DATARES()
                    {
                        ERROR = new ERRORRES()
                        {
                            ERRCODE = ConfigType.RS_SUCCESS,
                            ERRDESC = ConfigType.RS_SUCCESS_MESS
                        }
                    };
                }
                else
                {
                    response.DATA = new DATARES()
                    {
                        ERROR = new ERRORRES()
                        {
                            ERRCODE = ConfigType.RS_PASSWORD_FAIL,
                            ERRDESC = ConfigType.RS_PASSWORD_FAIL_MESS
                        }
                    };
                }
            }
            catch (Exception ex)
            {
                response.DATA = new DATARES()
                {
                    ERROR = new ERRORRES()
                    {
                        ERRCODE = ConfigType.RS_SYSTEM_ERROR,
                        ERRDESC = ConfigType.RS_SYSTEM_ERROR_MESS
                    }
                };
                logger.Error(ex);
            }
            string responseXML = ConvertXML.ModelToXMLString <SMSRS>(response);

            logger.Info("Response: " + responseXML);
            //ResultModel result = new ResultModel()
            //{
            //    xmlres = Server.UrlEncode(responseXML),
            //};
            //return result;
            return(Server.HtmlEncode(responseXML));
        }
예제 #11
0
        public HttpResponseMessage LoginIn(LoginUserMoel loginUser)
        {
            var systemUser = commonService.GetSystemUserByNTId(loginUser.UserName, 1);

            if (systemUser == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "ACCOUNT NOT EXIST"));
            }
            if (systemUser.Enable_Flag == false)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "ACCOUNT NOT ENABLED"));
            }

            //var userInfo = commonService.GetUserInfo(systemUser.Account_UID);

            var LDAPswitch = ConfigurationManager.AppSettings["LDAPAuthentication"].ToString();

            //判断WebConfig里面是否开启了需要输入密码登录
            if (!string.IsNullOrWhiteSpace(LDAPswitch) && LDAPswitch.Equals("ON", StringComparison.CurrentCultureIgnoreCase))
            {
                ValidateUser validateUser = new ValidateUser(settingService);
                //如果是物料员登录,则要判断是成都还是无锡的专案,成都的不需要输入密码,无锡的需要输入密码
                if (systemUser.MH_Flag)
                {
                    var projectSite = commonService.GetProjectSite(systemUser.Account_UID);
                    switch (projectSite)
                    {
                    case "CTU":
                        break;

                    case "WUXI_M":
                        if (string.IsNullOrEmpty(loginUser.Password) ||
                            !validateUser.LDAPValidateByMHFlag(loginUser.UserName, loginUser.Password, loginUser.IsEmployee))
                        {
                            return(Request.CreateResponse(HttpStatusCode.Unauthorized, "WRONG PASSWORD"));
                        }
                        break;
                    }
                }
                else if (systemUser.RoleList != null && systemUser.RoleList.Exists(x => x.Role_ID == "PlayBoardPlayUser"))
                {
                    //硬编码的角色Role_ID,这个角色免密码登录,直接显示播放看板
                    //PlayBoardPlayUser 播放看板播放账号
                }
                else if (systemUser.User_Name.Contains("电子看板"))
                {
                }
                else
                {
                    if (string.IsNullOrEmpty(loginUser.Password) ||
                        !validateUser.LDAPValidate(loginUser.UserName, loginUser.Password, loginUser.IsEmployee))
                    {
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized, "WRONG PASSWORD"));
                    }

                    //loginUser.Password = "******";
                }
                //如果不是物料员帐号登录则需要密码

                //if (!systemUser.MH_Flag && !systemUser.User_Name.Contains("电子看板"))
                //{
                //    //LDAP Authentication

                //    ValidateUser validateUser = new ValidateUser(settingService);
                //    if (string.IsNullOrEmpty(loginUser.Password) ||
                //        !validateUser.LDAPValidate(loginUser.UserName, loginUser.Password, loginUser.IsEmployee))
                //    {
                //        return Request.CreateResponse(HttpStatusCode.Unauthorized, "WRONG PASSWORD");
                //    }
                //}
                //else
                //    loginUser.Password = "******";
            }
            else
            {
                loginUser.Password = string.Empty;
            }

            //登录后,更新登录时间

            systemService.updateLastLoginDate(systemUser.Account_UID);
            //从db获取token数据并解密
            var  userlogintoken = string.Empty;
            bool refresh        = systemUser.LoginToken == null;
            FormsAuthenticationTicket ticket = null;

            if (!refresh)
            {
                userlogintoken = systemUser.LoginToken;

                try
                {
                    ticket = FormsAuthentication.Decrypt(userlogintoken);
                }
                catch
                {
                    refresh = true;
                }
            }

            if (refresh || loginUser.Password != ticket.UserData || loginUser.UserName != ticket.Name)
            {
                //userlogintoken = ReFreshToken(systemUser.Account_UID, loginUser.Password);
            }

            return(Request.CreateResponse(new AuthorizedLoginUser {
                Account_UID = systemUser.Account_UID,
                User_Name = systemUser.User_Name,
                System_Language_UID = systemUser.System_Language_UID,
                Token = userlogintoken,
                MH_Flag = systemUser.MH_Flag,
                IsMulitProject = systemUser.IsMulitProject,
                flowChartMaster_Uid = systemUser.flowChartMaster_Uid,
                USER_Ntid = systemUser.User_NTID,
                RoleList = systemUser.RoleList
            }));
        }
예제 #12
0
 public UserResObj ValidateUser([FromBody] ValidateUser user)
 {
     return(new UserService(_db).validateUser(user.email, user.token, user.pushID));
 }
예제 #13
0
        public ValidUser AddNewUser([FromBody] TotalUser User)
        {
            String    resp;
            ValidUser DemoUser = new ValidUser();

            try
            {
                //ViewSocietyUsers
                var context = new NestinDBEntities();
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    var users = (from USER in context.TotalUsers
                                 where USER.MobileNo == User.MobileNo || USER.EmailId == User.EmailId
                                 select USER);
                    if (users.Count() > 0)
                    {
                        DemoUser.result  = "Duplicate";
                        DemoUser.message = "Mobile or Email Id is in use";

                        //return BadRequest();

                        //resp = "{\"Response\":\"Fail\"}";
                        //var response = Request.CreateResponse(HttpStatusCode.BadRequest);
                        //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                        //return response;

                        return(DemoUser);
                    }
                    else
                    {
                        String encryptPwd = ValidateUser.EncryptPassword(User.EmailId, User.Password);
                        User.Password = encryptPwd;

                        // Add User
                        context.TotalUsers.Add(User
                                               );
                        context.SaveChanges();

                        context.SaveChanges();
                        dbContextTransaction.Commit();
                        User.Password     = "";
                        DemoUser.UserData = User;
                        DemoUser.result   = "Ok";

                        var sub       = "Your User Login is created";
                        var EmailBody = "Dear User \n You have successfully Registered with Nestin.Online. Please select your Role from Role Page";
                        var smsBody   = "Welcome to Nestin.online. your Registration is succesfull.";

                        Utility.SendMail(User.EmailId, sub, EmailBody);
                        Utility.sendSMS2Resident(smsBody, User.MobileNo);

                        //return Ok();
                        //resp = "{\"Response\":\"Ok\"}";
                        //var response = Request.CreateResponse(HttpStatusCode.OK);
                        //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                        return(DemoUser);
                    }
                }
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex.InnerException);
                //resp = "{\"Response\":\"Fail\"}";
                //var response = Request.CreateResponse(HttpStatusCode.InternalServerError);
                //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                //return response;

                DemoUser.result  = "Fail";
                DemoUser.message = "Server Error";
                return(DemoUser);
            }
        }
예제 #14
0
        public ValidUser IsValid([FromBody] ValidateUser ValUser)
        {
            Log.log("Reached Validate At " + DateTime.Now.ToString());
            var ValidUser = new ValidUser();

            try
            {
                using (var context = new NestinDBEntities())
                {
                    if (ValUser.Email == null && ValUser.Mobile == null)
                    {
                        Log.log("Both are null " + DateTime.Now.ToString());
                        ValidUser.result  = "Fail";
                        ValidUser.message = "Email and Maobile are null";
                        return(ValidUser);
                    }

                    else if (ValUser.Email == null || ValUser.Email == "")
                    {
                        Log.log("one is valid " + DateTime.Now.ToString());
                        var users = (from USER in context.TotalUsers
                                     where USER.MobileNo == ValUser.Mobile
                                     select USER).ToList();
                        if (users.Count() > 0)
                        {
                            ValUser.Email = users.First().EmailId;
                        }
                        else
                        {
                            ValidUser.result  = "Fail";
                            ValidUser.message = "Mobile Number is incorrect";
                            return(ValidUser);
                        }
                    }
                    String encPwd = ValidateUser.EncryptPassword(ValUser.Email.ToLower(), ValUser.Password);

                    Log.log("Encrypted Password is :" + encPwd + " At " + DateTime.Now.ToString());

                    var L2EQuery = context.TotalUsers.Where(u => (u.UserLogin.ToLower() == ValUser.Email.ToLower() ||
                                                                  u.MobileNo == ValUser.Mobile) && u.Password == encPwd);
                    var user = L2EQuery.FirstOrDefault();


                    if (user != null)
                    {
                        Log.log(user.FirstName);
                        if (ValUser.RegistrationID != null && ValUser.RegistrationID != "")
                        {
                            var GCM = context.GCMLists;
                            var reg = GCM.Where(g => g.UserId == user.UserID);
                            if (reg.Count() == 0)
                            {
                                GCM.Add(new GCMList
                                {
                                    UserId = user.UserID,
                                    RegID  = ValUser.RegistrationID,
                                    Topic  = "",
                                });
                            }
                            else
                            {
                                reg.First().RegID = ValUser.RegistrationID;
                            }
                            context.SaveChanges();
                        }
                        ValidUser.result   = "Ok";
                        ValidUser.UserData = user;

                        ValidUser.SocietyUser = (from res in context.ViewSocietyUsers
                                                 where (res.UserID == user.UserID &&
                                                        res.statusID == 2 &&
                                                        DbFunctions.TruncateTime(res.DeActiveDate) > DbFunctions.TruncateTime(DateTime.UtcNow) &&
                                                        DbFunctions.TruncateTime(res.ActiveDate) <= DbFunctions.TruncateTime(DateTime.UtcNow))
                                                 select res).ToList();
                    }
                    else
                    {
                        ValidUser.result             = "Fail";
                        ValidUser.message            = "No Valid User";
                        ValidUser.UserData.FirstName = "";
                        ValidUser.UserData.LastName  = "";
                    }
                }
            }
            catch (Exception ex)
            {
                Log.log(ex.Message);
                ValidUser.result             = "Fail";
                ValidUser.message            = "Server Error";
                ValidUser.UserData.FirstName = "";
                ValidUser.UserData.LastName  = "";
            }
            return(ValidUser);
        }
예제 #15
0
 public CheckIsActive(ValidateUser validateUser) : base(validateUser)
 {
 }
예제 #16
0
        public ValidUser AddUser([FromBody] TotalUser User)
        {
            String    resp;
            ValidUser DemoUser = new ValidUser();

            try
            {
                var context = new NestinDBEntities();
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    var users = (from USER in context.ViewSocietyUsers
                                 where USER.MobileNo == User.MobileNo || USER.EmailId == User.EmailId
                                 select USER);
                    if (users.Count() > 0)
                    {
                        DemoUser.result  = "Duplicate";
                        DemoUser.message = "Mobile or Email Id is in use";

                        //return BadRequest();

                        //resp = "{\"Response\":\"Fail\"}";
                        //var response = Request.CreateResponse(HttpStatusCode.BadRequest);
                        //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                        //return response;

                        return(DemoUser);
                    }
                    else
                    {
                        String encryptPwd = ValidateUser.EncryptPassword(User.EmailId, User.Password);
                        User.Password = encryptPwd;

                        // Add User
                        context.TotalUsers.Add(User
                                               );
                        context.SaveChanges();

                        Flat newFlat = new Flat
                        {
                            FlatNumber     = User.FirstName.Substring(0, 1) + User.LastName.Substring(0, 1) + User.MobileNo.Substring(7, 3),
                            BHK            = 3,
                            Block          = User.FirstName.Substring(0, 1),
                            FlatArea       = "1200",
                            Floor          = Convert.ToInt32(User.MobileNo.Substring(9, 1)),
                            IntercomNumber = Convert.ToInt32(User.MobileNo.Substring(5, 5)),
                            SocietyID      = 1,
                            UserID         = User.UserID
                        };
                        // Add Flat
                        context.Flats.Add(newFlat);
                        context.SaveChanges();

                        SocietyUser demoSocietyUser = new SocietyUser
                        {
                            UserID       = User.UserID,
                            SocietyID    = 1,
                            ActiveDate   = DateTime.UtcNow,
                            CompanyName  = "",
                            DeActiveDate = DateTime.UtcNow.AddDays(15),
                            FlatID       = newFlat.ID,
                            ModifiedDate = DateTime.UtcNow,
                            ServiceType  = 0,
                            Status       = 2,
                            Type         = "Owner"
                        };



                        context.SocietyUsers.Add(demoSocietyUser);

                        context.SaveChanges();
                        dbContextTransaction.Commit();
                        var socUser = context.ViewSocietyUsers.Where(x => x.ResID == demoSocietyUser.ResID).First();
                        DemoUser.UserData = User;
                        DemoUser.result   = "Ok";
                        DemoUser.SocietyUser.Add(socUser);

                        var sub       = "Your Demo ID is created";
                        var EmailBody = "Dear User \n You have successfully Registered with Nestin.Online For Demo. You demo will run for 15 days. Please" +
                                        "Explore the application and contact us for any further query";
                        var smsBody = "Welcome to Nestin.online. your demo login is valid for 15 days.";

                        Utility.SendMail(User.EmailId, sub, EmailBody);
                        Utility.sendSMS2Resident(smsBody, User.MobileNo);
                        //return Ok();
                        //resp = "{\"Response\":\"Ok\"}";
                        //var response = Request.CreateResponse(HttpStatusCode.OK);
                        //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                        return(DemoUser);
                    }
                }
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex.InnerException);
                //resp = "{\"Response\":\"Fail\"}";
                //var response = Request.CreateResponse(HttpStatusCode.InternalServerError);
                //response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
                //return response;

                DemoUser.result  = "Fail";
                DemoUser.message = "Server Error";
                return(DemoUser);
            }
        }
예제 #17
0
        public ForgotPasswordValidator(IQueryEntities entities, IStorePasswords passwords)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            Establishment establishment     = null;
            var           loadEstablishment = new Expression <Func <Establishment, object> >[]
            {
                e => e.SamlSignOn,
            };

            Person person     = null;
            var    loadPerson = new Expression <Func <Person, object> >[]
            {
                p => p.Emails,
                p => p.User
            };

            RuleFor(p => p.EmailAddress)

            // cannot be empty
            .NotEmpty()
            .WithMessage(FailedBecauseEmailAddressWasEmpty)

            // must be valid against email address regular expression
            .EmailAddress()
            .WithMessage(FailedBecauseEmailAddressWasNotValidEmailAddress)

            // must match an establishment
            .Must(p => ValidateEstablishment.EmailMatchesEntity(p, entities, loadEstablishment, out establishment))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // establishment must be a member
            .Must(p => establishment.IsMember)
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // establishment cannot have saml integration
            .Must(p => !establishment.HasSamlSignOn())
            .WithMessage(FailedBecauseEduPersonTargetedIdWasNotEmpty,
                         p => p.EmailAddress.GetEmailDomain())

            // must match a person
            .Must(p => ValidateEmailAddress.ValueMatchesPerson(p, entities, loadPerson, out person))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the matched person must have a user
            .Must(p => ValidatePerson.UserIsNotNull(person))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the user must not have a SAML account
            .Must(p => ValidateUser.EduPersonTargetedIdIsEmpty(person.User))
            .WithMessage(FailedBecauseEduPersonTargetedIdWasNotEmpty,
                         p => p.EmailAddress.GetEmailDomain())

            // the email address' person's user's name must match a local member account
            .Must(p => ValidateUser.NameMatchesLocalMember(person.User.Name, passwords))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the email address must be confirmed
            .Must(p => ValidateEmailAddress.IsConfirmed(person.GetEmail(p)))
            .WithMessage(ValidateEmailAddress.FailedBecauseIsNotConfirmed,
                         p => p.EmailAddress)
            ;
        }
예제 #18
0
 public UserResObj ValidateUser([FromBody] ValidateUser user)
 {
     return(new BLL.BLL_Users(_db).validateUser(user.email, user.token, user.pushID));
 }
 public async Task <User> SignIn(LoginData loginData)
 {
     return(await ValidateUser.ValidateLoginAsync(loginData));
 }
예제 #20
0
 public CheckPhoneConfirmed(ValidateUser validateUser) : base(validateUser)
 {
 }
 public async Task <string> GetUserRole(LoginData loginData)
 {
     return(await ValidateUser.GetUserRoleAsync(loginData));
 }
 public async Task <User> Register(Tourist tourist, LoginData loginData)
 {
     return(await ValidateUser.ValidateRegisterAsync(tourist, loginData));
 }
예제 #23
0
 public override bool IsValid()
 {
     ValidationResult = new ValidateUser().Validate(this);
     return(ValidationResult.IsValid);
 }
예제 #24
0
        private void pswdSubmit_Click(object sender, RoutedEventArgs e)
        {
            // Zkontrolovat původní heslo
            bool isUserAuthentificated = false;

            try
            {
                string enteredPswd = ValidateUser.ValidatePassword(pbFormerPswd.Password);
                if (Authentification.CheckUserPassword(enteredPswd))
                {
                    // Heslo ověřeno, pokračujeme dále --> kontrola nového hesla
                    isUserAuthentificated = true;
                }
                else
                {
                    DialogHelper.ShowWarning("Původní heslo nebylo zadáno správně.");
                    pbFormerPswd.Password = string.Empty;
                }
            }
            catch (UserNotLoggedInException ex)
            {
                DialogHelper.ShowError(ex.Message);
            }
            catch (InvalidAuthPasswordException ex)
            {
                DialogHelper.ShowWarning(ex.Message);
            }
            catch
            {
                DialogHelper.ShowError("Uživatel nemohl být ověřen.");
            }

            // Validace nového hesla
            if (isUserAuthentificated)
            {
                try
                {
                    string newPswd      = ValidateUser.ValidateNewPassword(pbNewPswd.Password);
                    string newPswdAgain = pbNewPswdAgain.Password;
                    if (newPswd == newPswdAgain)
                    {
                        Authentification.ChangePassword(Authentification.AuthUser.Id, newPswd);
                        DialogHelper.ShowInfo("Heslo bylo úspěšně změněno.");
                        InitializeInterface();
                    }
                    else
                    {
                        throw new PasswordsDoNotMatchException();
                    }
                }
                catch (InvalidNewPasswordException ex)
                {
                    DialogHelper.ShowWarning(ex.Message);
                }
                catch (PasswordsDoNotMatchException ex)
                {
                    DialogHelper.ShowWarning(ex.Message);
                }
                catch
                {
                    DialogHelper.ShowError("Heslo nemohlo být změněno.");
                }
            }
        }
예제 #25
0
 public CheckIsLockedAccount(ValidateUser validateUser) : base(validateUser)
 {
 }