internal void OnLogedIn(LogInResult lir) { //Debug.Log("RegisterCanvasMediator OnLogedIn" + isLogedIn); if (lir.isLogedIn && lir.isConnected)//登录成功 { view.Hide(); OnRemove(); } else if (lir.isConnected)//连接成功 { DialogBoxMsg msg = new DialogBoxMsg(); msg.tittle = "用户名称不存在"; msg.msg = "请您输入正确的用户名,或联系管理员"; dialogBoxSignal.Dispatch(msg); } else//连接不成功 { DialogBoxMsg msg = new DialogBoxMsg(); msg.tittle = "服务器IP不存在"; msg.msg = "请您输入正确服务器IP,或联系管理员"; msg.resultSignal = new DialogBoxResultSignal(); msg.resultSignal.AddListener(OnDialogBoxTest); dialogBoxSignal.Dispatch(msg); } }
private LogInResult CheckUserLogInForWindowAuthen(string USER_ID) { LogInResult enmLogInResult = LogInResult.Success; var da = new UserDA(); da.DTO.Execute.ExecuteType = UserExecuteType.GetUser; da.DTO.Model.COM_CODE = "AAT"; // ไม่ได้ใช้ da.DTO.Model.USER_ID = USER_ID; //ส่งไปใช้แค่ตัวนี้อย่างเดียว da.Select(da.DTO); if (da.DTO.Result.IsResult) { Session[SessionSystemName.SYS_COM_CODE] = da.DTO.Model.COM_CODE; Session[SessionSystemName.SYS_USER_ID] = da.DTO.Model.USER_ID; Session[SessionSystemName.SYS_USER_FNAME_TH] = da.DTO.Model.USER_FNAME_TH; Session[SessionSystemName.SYS_USER_FNAME_EN] = da.DTO.Model.USER_FNAME_EN; Session[SessionSystemName.SYS_USER_LNAME_TH] = da.DTO.Model.USER_LNAME_TH; Session[SessionSystemName.SYS_USER_LNAME_EN] = da.DTO.Model.USER_LNAME_EN; Session[SessionSystemName.SYS_USG_ID] = da.DTO.Model.USG_ID; Session[SessionSystemName.SYS_COM_NAME_TH] = da.DTO.Model.COM_NAME_T; Session[SessionSystemName.SYS_COM_NAME_EN] = da.DTO.Model.COM_NAME_E; Session[SessionSystemName.SYS_USG_LEVEL] = da.DTO.Model.USG_LEVEL; } else { enmLogInResult = LogInResult.UserGroupNotAuthorized; } return(enmLogInResult); }
public IHttpActionResult AdminLogin(LogInModel Model) { LogInResult resModel = new LogInResult(); String newID = Shuffle(Model.ID); resModel.ID = newID; resModel.Result = false; SQL_function sql_function = new SQL_function(); String strQuery_auth = @"SELECT COUNT(*) FROM [DuLieuTotNghiep].[dbo].[Account] WHERE [UserName] = @UserName and [Password] =@Password "; SqlCommand cmd_auth = new SqlCommand(strQuery_auth); cmd_auth.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = Model.UserName; cmd_auth.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Model.Password; String[,] array_auth = sql_function.xml_deserialize(sql_function.GetData(cmd_auth, "sqlconnString")); if (array_auth[0, 0] == "1") { String strQuery = @"UPDATE [dbo].[Session] SET ID =@newID ,[UserName] = @UserName WHERE ID = @ID"; SqlCommand cmd = new SqlCommand(strQuery); cmd.Parameters.Add("@newID", SqlDbType.NVarChar).Value = newID; cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = "admin"; cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value = Model.ID; String insertRes = sql_function.InsertUpdateData(cmd, "sqlconnString"); if (insertRes == "1") { resModel.Result = true; } } return(Json(resModel)); }
private void OnLogedIn(LogInResult lir) { if (lir.isLogedIn) { view.Show(); } }
public async Task <IActionResult> CustomerAccountConfirm(UserConfirmAccountForm form) { try { Helper.ThrowIfIsNullOrEmpty(form.UserName, "Usuario inválido"); Helper.ThrowIfIsNullOrEmpty(form.VerifyCode, "Código de verificación inválido"); string baseAuthUrl = Configuration.GetSection("Jwt:AuthorityUrl").Value; string applicationName = Configuration.GetSection("AppConfig:Name").Value; string domainName = Configuration.GetSection("Jwt:Audience").Value; string authField = Configuration.GetSection("AppConfig:AuthenticationField").Value; string authUri = Configuration.GetSection("Jwt:AuthUri").Value; using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(baseAuthUrl); var obj = new { UserName = form.UserName, VerifyCode = form.VerifyCode, ApplicationName = applicationName, DomainName = domainName, AuthenticationField = authField }; string json = JsonConvert.SerializeObject(obj); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage result = await httpClient.PostAsync(authUri + "/ConfirmAccount", content); if (result.StatusCode == HttpStatusCode.OK) { Customer customer = userLogic.CustomerExists(form.UserName); Helper.ThrowIf(customer == null, "No se encontró la cuenta para el email especificado"); User user = userLogic.CreateUser(customer.FirstName, customer.LastName, customer.Email); LogInResult logInResult = await result.Content.ReadAsAsync(typeof(LogInResult)) as LogInResult; return(Ok(logInResult)); } else { string message = await result.Content.ReadAsStringAsync(); if (string.IsNullOrEmpty(message) && result.StatusCode == HttpStatusCode.NotFound) { throw new Exception(AUTH_SERVICE_NOT_AVAILABLE); } return(NotFound(new { Message = message })); } } } catch (ArgumentException ex) { return(NotFound(new { Message = ex.Message })); } catch (Exception ex) { Logger.LogError(ex, "CustomerAccountConfirm method"); return(NotFound(new { Message = "Ocurrió un error." })); } }
public async Task <ILogInResult> CheckPasswordSignInAsync(DomainUser user, string password) { var result = await _signInManager.CheckPasswordSignInAsync(user, password, true); var logInResult = new LogInResult(result.Succeeded, result.IsLockedOut, result.IsNotAllowed); return(logInResult); }
public ActionResult SignIn(string returnUrl, string Username) { ViewBag.message = string.Empty; ViewBag.messageHeader = string.Empty; string cdsid = Username; if (!string.IsNullOrEmpty(Request.ServerVariables["AUTH_USER"].ToString().Trim())) { cdsid = Request.ServerVariables["AUTH_USER"].ToString().Split('\\')[0]; } SECS02P002Model dsSys = GET_VSMS_USER(cdsid); if (!dsSys.USER_ID.IsNullOrEmpty()) { if (dsSys.IS_DISABLED == "Y") { ViewBag.message = string.Concat("-", "Your account is disabled,please contact your system administrator", "<br/>"); } else { if (!dsSys.COM_CODE.IsNullOrEmpty() && !dsSys.USG_ID.IsNullOrEmpty()) { SECS02P001Model dsUSerGroup = GET_VSMS_USRGROUP(dsSys.COM_CODE, dsSys.USG_ID); if (!dsUSerGroup.COM_CODE.IsNullOrEmpty() && dsUSerGroup.USG_ID != null && !dsUSerGroup.USG_CODE.IsNullOrEmpty()) { if (!dsUSerGroup.USG_STATUS.IsNullOrEmpty() && dsUSerGroup.USG_STATUS == "D") { ViewBag.message = string.Concat("-", "Your user group is disable,plase contarct your system administrator", "<br/>"); } else { FormsAuthentication.SetAuthCookie(cdsid.Trim(), false); LogInResult enmLogInResult = CheckUserLogInForWindowAuthen(cdsid.Trim()); if (enmLogInResult == LogInResult.WrongUserNameOrPassword) { ViewBag.message = string.Concat("-", "Wrong username or password", "<br/>"); } else if (enmLogInResult == LogInResult.Success) { return(RedirectToAction("SelectModule")); } } } } } } else { ViewBag.message = string.Concat("User ", cdsid, ": Wrong user name or password"); } return(View("SignIn")); }
public LogInResult GetUser() { LogInResult logInResult = new LogInResult(); IAuthenticationResponse openIdResponse = openId.GetResponse(); if (openIdResponse.IsSuccessful()) { logInResult = ResponseIntoUser(openIdResponse); } return(logInResult); }
public async Task <IActionResult> LogIn(UserForm userForm) { try { string baseAuthUrl = Configuration.GetSection("Jwt:AuthorityUrl").Value; string applicationName = Configuration.GetSection("AppConfig:Name").Value; string domainName = Configuration.GetSection("Jwt:Audience").Value; string authField = Configuration.GetSection("AppConfig:AuthenticationField").Value; string authUri = Configuration.GetSection("Jwt:AuthUri").Value; using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(baseAuthUrl); var obj = new { UserName = userForm.UserName, Password = userForm.Password, ApplicationName = applicationName, DomainName = domainName, AuthenticationField = authField, TokenExpirationMinutes = 60 * 24 }; string json = JsonConvert.SerializeObject(obj); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage result = await httpClient.PostAsync(authUri + "/LogIn", content); if (result.StatusCode == HttpStatusCode.OK) { LogInResult logInResult = await result.Content.ReadAsAsync(typeof(LogInResult)) as LogInResult; return(Ok(logInResult)); } string message = await result.Content.ReadAsStringAsync(); if (string.IsNullOrEmpty(message) && result.StatusCode == HttpStatusCode.NotFound) { throw new Exception(AUTH_SERVICE_NOT_AVAILABLE); } return(NotFound(new { Message = message })); } } catch (Exception ex) { Logger.LogError(ex, "LogIn method"); return(BadRequest(new { Message = "Ocurrió un error" })); } }
public Command(ICommandReporter commandReporter, string username, string password, string server, string vault, string outputFolder, bool useWorkingFolder, bool failOnError, CancellationToken ct) { if (commandReporter == null) { throw new ArgumentNullException("commandReporter)"); } m_commandReporter = commandReporter; m_vault = vault; // add the vault name to the local path. This prevents users from accedently // wiping out their C drive or something like that. m_useWorkingFolder = useWorkingFolder; if (!m_useWorkingFolder) { m_outputFolder = UseWorkingFolder ? outputFolder : Path.Combine(outputFolder, VaultName); } m_failOnError = failOnError; m_ct = ct; ChangeStatusMessage("Logging in..."); Func <string, LoginStates, bool> progressCallback = (m, s) => !m_ct.IsCancellationRequested; LogInResult result = Library.ConnectionManager.LogIn(server, vault, username, password, AuthenticationFlags.ReadOnly, progressCallback); ThrowIfCancellationRequested(); m_conn = result.Connection; if (!result.Success && result.Exception != null) { throw result.Exception; } else if (!result.Success && result.ErrorMessages.Any()) { throw new Exception(result.ErrorMessages.Values.FirstOrDefault()); } else if (!result.Success) { throw new Exception("Unknown Error"); } m_aquireFilesSettings = CreateAcquireFileSettings(); }
private LogInResult BuildResult(LogInViewModel login) { var principal = this.CreatePrincipalFor(login); var authorizationTicket = SignInHelper.CreateAuthenticationTicketFor(principal, login.RememberMe); SignInHelper.SetAuthorizationCookie(authorizationTicket); var result = new LogInResult() { Success = true, FirstName = principal.FirstName, LastName = principal.LastName, CompanyName = principal.CompanyName }; result.TargetUrl = FormsAuthentication.GetRedirectUrl(login.Name, true); return(result); }
public async Task <IActionResult> LogIn([FromBody] LogInRequest request) { var session = await _sessionService.LogIn(request.UserName, request.Password, HttpContext.Connection.Id); if (session == null) { return(BadRequest(new { message = "Username or password is incorrect" })); } var userDetails = await _userRepository.GetDetails(session.UserId); var result = new LogInResult { Username = session.UserId, FirstName = string.IsNullOrEmpty(userDetails.FirstName)? session.UserId: userDetails.FirstName, LastName = userDetails.LastName, Token = session.SessionToken }; return(Ok(result)); }
public async Task <IActionResult> LogIn(UserForm userForm) { try { string baseAuthUrl = Configuration.GetSection("Authority").Value; string applicationName = Configuration.GetSection("AppConfig:Name").Value; string domainName = Configuration.GetSection("Audience").Value; string authField = Configuration.GetSection("AuthenticationField").Value; string authUri = Configuration.GetSection("AuthUri").Value; HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(baseAuthUrl); var obj = new { UserName = userForm.UserName, Password = userForm.Password, ApplicationName = applicationName, DomainName = domainName, AuthenticationField = authField }; string json = JsonConvert.SerializeObject(obj); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage result = await httpClient.PostAsync(authUri, content); if (result.StatusCode == HttpStatusCode.OK) { LogInResult logInResult = await result.Content.ReadAsAsync(typeof(LogInResult)) as LogInResult; return(Ok(logInResult)); } return(NotFound(new { Message = "Usuario o contraseña inválido" })); } catch (Exception ex) { Logger.LogError(ex, "LogIn method"); return(BadRequest("Ocurrió un error")); } }
/// <summary> /// /// </summary> /// <param name="login"></param> /// <returns></returns> public LogInResult PerformLogInAction(LoginDto login) { LogInResult result = new LogInResult() { IsValidUser = false }; Users user = userRepo.GetUserByLoginInformation(login); if (user != null) { // Retrieve claims of current user result.ClaimsCollection = Mapper.Map <ICollection <Claim> >(claimRepo.GetListOfClaimsForUser(user.UserId.ToString())); // Additionaly add userId as a claim result.ClaimsCollection.Add(new Claim(CLAIM_USER_ID, user.UserId.ToString(), "")); result.UserId = user.UserId.ToString(); result.User = user; result.IsValidUser = true; } return(result); }
public ActionResult SignIn(string returnUrl, string Username, string Password) { ViewBag.message = string.Empty; ViewBag.messageHeader = string.Empty; //string cdsid = string.Empty; string cdsid = Username; //ตรวจสอบการ auth user if (!string.IsNullOrEmpty(Request.ServerVariables["AUTH_USER"].ToString().Trim())) { // cdsid = Request.ServerVariables["AUTH_USER"].ToString().Split('\\')[1]; cdsid = Request.ServerVariables["AUTH_USER"].ToString().Split('\\')[0]; } //เก็บค่าที่ auth user ไว้ที่ cdsid เพื่อเช็๕ใน VSMS_USER SEC006P001Model dsSys = GET_VSMS_USER(cdsid); //ถ้าหาเจอ if (!dsSys.USER_ID.IsNullOrEmpty()) { //ตรวจสอบค่าจาก dsSys ว่าสถานะเป็น DISABLED หรือไม่ if (dsSys.IS_DISABLED == "Y") { ViewBag.message = string.Concat("-", "Your account is disabled,please contact your system administrator", "<br/>"); } else { //ถ้าค่า COM_CODE และ USG_ID ใน dsSys ไม่เท่ากับ Null หรือ Empty if (!dsSys.COM_CODE.IsNullOrEmpty() && !dsSys.USG_ID.IsNullOrEmpty()) { //เอาค่า COM_CODE และ USG_ID ไป query ใน vsms_usgroup SEC007P001Model dsUSerGroup = GET_VSMS_USRGROUP(dsSys.COM_CODE, dsSys.USG_ID); if (!dsUSerGroup.COM_CODE.IsNullOrEmpty() && dsUSerGroup.USG_ID != null && !dsUSerGroup.USG_CODE.IsNullOrEmpty()) { //ถ้า USG_STATUS = D if (!dsUSerGroup.USG_STATUS.IsNullOrEmpty() && dsUSerGroup.USG_STATUS == "D") { ViewBag.message = string.Concat("-", "Your user group is disable,plase contarct your system administrator", "<br/>"); } else { //ไม่รู้ FormsAuthentication.SetAuthCookie(cdsid.Trim(), false); //เก็บ secssion LogInResult enmLogInResult = CheckUserLogInForWindowAuthen(cdsid.Trim()); if (enmLogInResult == LogInResult.WrongUserNameOrPassword) { ViewBag.message = string.Concat("-", "Wrong username or password", "<br/>"); } else if (enmLogInResult == LogInResult.Success) { //return RedirectToAction("SelectModule"); return(RedirectToAction("SelectSystem")); } } } } } } else { //หา user_id ไม่เจอ ViewBag.message = string.Concat("User ", cdsid, ": Wrong user name or password"); } return(View("SignIn")); }
private IEnumerator WaitClientRegister(LogInInfo logInfo) { for (int i = 0; i < 10; i++) { if (client.connectState == ConnectState.isConnecting) { yield return(new WaitForSeconds(0.15f)); } else { break; } } //如果连接没成功则返回false if (client.connectState != ConnectState.connected) { client.Close();//关闭client连接 LogInResult lir = new LogInResult(); lir.isLogedIn = false; lir.isConnected = false; lir.msg = null; globalLogedInSignal.Dispatch(lir); yield break; } //登录服务器 LogedInSignal TransferCommand tfc = new TransferCommand(1, 2, TransferCommand.UserStyle.Unkown, logInfo.name); client.SendData(tfc); TransferCommand registerTFC = null; for (int i = 0; i < 10; i++) { registerTFC = client.GetReceivedTransferCommand(); if (registerTFC == null) { yield return(new WaitForSeconds(0.15f)); } else { break; } } if (registerTFC == null) { client.Close();//关闭client连接 LogInResult lir = new LogInResult(); lir.isConnected = true; lir.isLogedIn = false; lir.msg = "Error: recieve sever register msg timeout!"; globalLogedInSignal.Dispatch(lir); } else { if (registerTFC.userName == logInfo.name) { LogInResult lir = new LogInResult(); lir.isConnected = true; lir.userStyle = registerTFC.userStyle; lir.isLogedIn = true; globalLogedInSignal.Dispatch(lir); } } }
public ActionResult LogIn(UserLogInModel model) { LogInResult @out = new LogInResult { result = false }; PasswordError err; if ((model.Email ?? "").Length < 1) { @out.err_msg = "Pleause input email!"; } else if (!Validator.EmailIsValid(model.Email)) { @out.err_msg = "Incorrect email!"; } else if ((model.Password ?? "").Length < 1) { @out.err_msg = "Pleause input password!"; } else if (!Validator.PasswordIsValid(model.Password, out err)) { switch (err) { case PasswordError.Length: @out.err_msg = "Minimum 6 symbols, maximum 12 symbols"; break; case PasswordError.Whitespace: @out.err_msg = "No white space"; break; case PasswordError.Upper: @out.err_msg = "At least 1 upper case letter"; break; case PasswordError.Lover: @out.err_msg = "At least 1 lower case letter"; break; case PasswordError.SpecificSymbol: @out.err_msg = "At least 1 special char"; break; default: @out.err_msg = "ERROR"; break; } } else { AppUser user = UserManager.Find(model.Email, model.Password); if (user != null) { ClaimsIdentity claim = UserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claim); @out.result = true; } else { @out.err_msg = "Incorrect password or login"; } } return(Json(@out)); }
private LogInResult ResponseIntoUser(IAuthenticationResponse response) { LogInResult logInResult = new LogInResult(); logInResult.IsAuthenticated = true; var fetchResponse = response.GetExtension <FetchResponse>(); if (fetchResponse != null) { logInResult.User = new OpenIdUser(fetchResponse, response.ClaimedIdentifier); using (AllUsersRepository userRep = new AllUsersRepository()) using (PendingUsersRepository pendingUserRep = new PendingUsersRepository()) { User user = userRep.GetList().SingleOrDefault(x => x.Email == logInResult.User.Email); if (user != null) { if (user.IsActive) { if (user.FirstName != logInResult.User.FirstName || user.LastName != logInResult.User.LastName) { user.FirstName = logInResult.User.FirstName; user.LastName = logInResult.User.LastName; userRep.Update(user); } logInResult.IsRegistered = true; logInResult.User.UserId = user.Id; return(logInResult); } else { logInResult.IsRegistered = false; logInResult.IsCanceled = true; logInResult.User.UserId = user.Id; return(logInResult); } } else { PendingUser pendingUser = pendingUserRep.GetList().SingleOrDefault(x => x.Email == logInResult.User.Email); if (pendingUser != null) { User newUser = new User() { CompanyId = pendingUser.CompanyId, Email = logInResult.User.Email, FirstName = logInResult.User.FirstName, LastName = logInResult.User.LastName, CreationTime = DateTime.Now, LastLogInTime = DateTime.Now, Roles = pendingUser.Roles, LanguageId = pendingUser.LanguageId, IsActive = true }; if (!userRep.Create(newUser)) { return(logInResult); } logInResult.User.UserId = newUser.Id; pendingUserRep.Delete(pendingUser.Id); logInResult.IsNewUser = true; logInResult.IsRegistered = true; return(logInResult); } else { return(logInResult); } } } } else { return(logInResult); } }
/// <summary> /// Comprueba el inicio de sesión de un usuario y devuelve un estado que indica si ha sido exitoso o no. De no serlo, la respuesta indica la razón. /// </summary> /// <param name="username">Nombre de usuario.</param> /// <param name="password">Contraseña.</param> /// <param name="skipEmailConfirmed">¿Debe validarse que el email haya sido confirmado?</param> /// <returns></returns> public async Task <LogInResult> CheckCredentialsAsync(string username, string password, bool skipEmailConfirmed = false) { LogInResult result = new LogInResult(LoginStatusTypes.UnknownError); try { var user = await uM.FindByNameAsync(username); result = new LogInResult(LoginStatusTypes.UnknownError, user); if (user == null) { //No existe result.Status = LoginStatusTypes.DoesNotExist; return(result); } if (user.LockoutEnabled) { bool haltAndReturn = true; //Usuario bloqueado if (user.LockoutEnd.HasValue) { //El bloqueo es temporal. if (user.LockoutEnd.Value <= DateTimeOffset.Now) { //El bloqueo ha expirado: desbloquear & continuar. await uM.SetLockoutEnabledAsync(user, false); haltAndReturn = false; } else { ///El bloqueo sigue activo. result.Status = LoginStatusTypes.UserLocked_Temporal; } } else { //El bloqueo es permanente result.Status = LoginStatusTypes.UserLocked_Permanent; } if (haltAndReturn) { return(result); } } if (!skipEmailConfirmed) { if (!user.EmailConfirmed) { result.Status = LoginStatusTypes.EmailNotConfirmed; } return(result); } bool isPasswordValid = await uM.CheckPasswordAsync(user, password); if (!isPasswordValid) { result.Status = LoginStatusTypes.PasswordNotValid; return(result); } else { result.Status = LoginStatusTypes.Success; } } catch (Exception) { } return(result); }