private async void SignInPassport() { if (await MicrosoftPassportHelper.MicrosoftPassportAvailableCheckAsync()) { if (await MicrosoftPassportHelper.CreatePassportKeyAsync(thisuser.UserName)) { var _account = AccountHelper.AddAccount(thisuser.UserName); var dialog = new ContentDialog { Title = "Notice", Content = "You have successfully added this list", IsPrimaryButtonEnabled = true, PrimaryButtonText = "OK", }; await dialog.ShowAsync(); } } else { var dialog = new ContentDialog { Title = "Notice", Content = "Microsoft Passport is not setup!\n" + "Please go to Windows Settings and set up a PIN to use it.", IsPrimaryButtonEnabled = true, PrimaryButtonText = "OK", }; await dialog.ShowAsync(); } }
private async void SignInPassport() { if (_isExistingAccount) { if (await MicrosoftPassportHelper.GetPassportAuthenticationMessageAsync(_account)) { Frame.Navigate(typeof(Welcome), _account); } } else if (AccountHelper.ValidateAccountCredentials(UsernameTextBox.Text)) { //Create and add a new local account _account = AccountHelper.AddAccount(UsernameTextBox.Text); Debug.WriteLine("Successfully signed in with traditional credentials and created local account instance!"); if (await MicrosoftPassportHelper.CreatePassportKeyAsync(UsernameTextBox.Text)) { Debug.WriteLine("Successfully signed in with Microsoft Passport!"); Frame.Navigate(typeof(Welcome), _account); } } else { ErrorMessage.Text = "Invalid Credentials"; } }
private async void SignInPassport() { PassportSignInButton.IsEnabled = false; ErrorMessage.Text = "Validating..."; var username = UsernameTextBox.Text; if (AccountHelper.ValidateAccountCredentials(username)) { List <Account> accounts = await AccountHelper.LoadAccountListAsync(); int accountIndex = -1; for (var i = 0; i < accounts.Count; i++) { var account = accounts[i]; if (account.Username == username) { accountIndex = i; break; } } if (accountIndex == -1) { _account = AccountHelper.AddAccount(username); Debug.WriteLine("Successfully signed in with traditional credentials and created local account instance!"); } else { _account = accounts[accountIndex]; } if (await MicrosoftPassportHelper.CreatePassportKeyAsync(_account.Username)) { Debug.WriteLine("Successfully signed in with Microsoft Passport!"); (DataContext as ViewModels.LoginViewModel).DoLogin(); } ErrorMessage.Text = ""; } else { ErrorMessage.Text = "Invalid Credentials"; } PassportSignInButton.IsEnabled = true; }
private async void SignInFingerprint() { if (AccountHelper.ValidateAccountCredentials(UsernameTextBox.Text)) { // Create and add a new local account _account = AccountHelper.AddAccount(UsernameTextBox.Text); Debug.WriteLine("Successfully signed in with traditional credentials and created local account instance!"); } else { if (UsernameTextBox.Text == "") { ErrorMessage.Text = await RequestConsent("Probando con huella!!"); } else { ErrorMessage.Text = "Invalid Credentials"; } } }
void bttnRegister_Click(object sender, EventArgs e) { if (mv1.ActiveViewIndex == 1 && ValidateInput()) { try { string name = txtUser.Text.Trim(); string pwd = txtPassword.Text.Trim(); string email = txtEmail.Text.Trim(); Account act = new Account(); act.Created = DateTime.Now; act.Email = email; act.LoginName = name; act.Password = pwd; act.ModelName = ModelName; act.IsPasswordHashed = false; AccountHelper.AddAccount(act); AccountID = act.ID; if (SendEmail()) //不要模型,需要验证 { mv1.ActiveViewIndex = 3; ShowMessage(plValidate); } else if (UseModel) //需要模型 { mv1.ActiveViewIndex = 2; LoadModel(); } else //不要验证,与不要模型 { mv1.ActiveViewIndex = 3; ShowMessage(plSuccess); } } catch (Exception ex) { lblError.Text = ex.Message; } } }
/// <summary> /// Try to sign in to Microsoft Passport for authentication /// </summary> private async void SignInPassport() { if (AccountHelper.ValidateAccountCredentials(UsernameText)) { // Create and add a new local account userModel = AccountHelper.AddAccount(UsernameText); Debug.WriteLine("Successfully signed in with traditional credentials and created local account instance!"); if (await MicrosoftPassportHelper.CreatePassportKeyAsync(UsernameText)) { Debug.WriteLine("Successfully signed in with Microsoft Passport!"); // Since we go into here for the time being, lets navigate to the Map page NavigationService.Navigate(typeof(MapViewPage)); } } else { ErrorMessageText = "Invalid Credentials"; } }
private async void SignInPassport() { if (AccountHelper.ValidateAccountCredentials(UsernameTextBox.Text)) { // Create and add a new local account _account = AccountHelper.AddAccount(UsernameTextBox.Text); if (await MicrosoftPassportHelper.CreatePassportKeyAsync(UsernameTextBox.Text)) { _account.isUserLoggedIn = true; App.account = _account; this.Frame.Navigate(typeof(Frames.fHome)); } } else { ErrorMessage.Text = "Invalid Credentials"; } }
private async void FuckingRegisterMate() { if (!(UsernameTextBox.Text.Length > 0)) { ErrorMessage.Text = "Dude...."; return; } bool userNameExistsInFile = await AccountHelper.IsInFuckingFile(UsernameTextBox.Text); if (_AmIForeign) { //Pinsly if (await MicrosoftPassportHelper.GetPassportAuthenticationMessageAsync(_account)) { Frame.Navigate(typeof(Welcome), _account); } } else if (!userNameExistsInFile) { //Register new account with Microsoft Passport var amilegit = await MicrosoftPassportHelper.CreatePassportKeyAsync(UsernameTextBox.Text); if (amilegit) { //Register a new account _account = AccountHelper.AddAccount(UsernameTextBox.Text); //Navigate to the Welcome Screen. Frame.Navigate(typeof(Welcome), _account); } else { ErrorMessage.Text = "Error Signing in"; } } else { ErrorMessage.Text = "Yo dawg, u in already"; } }
public override bool Insert(We7.Model.Core.PanelContext data) { Account account = new Account(); account.ID = GetValue <string>(data, "ID"); account.LoginName = GetValue <string>(data, "LoginName"); account.Password = GetValue <string>(data, "Password"); account.FirstName = GetValue <string>(data, "FirstName"); account.LastName = GetValue <string>(data, "LastName"); account.MiddleName = GetValue <string>(data, "MiddleName"); account.Description = GetValue <string>(data, "Description"); account.Email = GetValue <string>(data, "Email"); account.QQ = GetValue <string>(data, "QQ"); account.Home = GetValue <string>(data, "Home"); account.Mobile = GetValue <string>(data, "Mobile"); //wangjz 添加目的是为了倒入数据是同步通过邮件验证 account.EmailValidate = GetValue <int>(data, "EmailValidate"); account.PasswordHashed = GetValue <int>(data, "PasswordHashed"); account.UserType = GetValue <int>(data, "UserType"); //end wangjz account.Updated = DateTime.Now; account.Created = DateTime.Now; //下面是添加模型信息 string config, schema; account.ModelXml = GetModelDataXml(data, account.ModelXml, out schema, out config);//获取模型数据 account.ModelConfig = config; account.ModelName = data.ModelName; account.ModelSchema = schema; AccountHelper.AddAccount(account); return(true); }
private async void RegisterButton_Click_Async(object sender, RoutedEventArgs e) { ErrorMessage.Text = ""; //In the real world you would normally validate the entered credentials and information before //allowing a user to register a new account. //For this sample though we will skip that step and just register an account if username is not null. if (!string.IsNullOrEmpty(UsernameTextBox.Text)) { //Register a new account _account = AccountHelper.AddAccount(UsernameTextBox.Text); //Register new account with Microsoft Passport await MicrosoftPassportHelper.CreatePassportKeyAsync(_account.Username); //Navigate to the Welcome Screen. Frame.Navigate(typeof(Welcome), _account); } else { ErrorMessage.Text = "Please enter a username"; } }
private void PassportSignInButton_Click(object sender, RoutedEventArgs e) { UserName = username.Text; pass = passw.Password; if (!safeManager.checkInjection(UserName)) { ErrorMessage.Text = "The input is unsafe"; } else if (userManager.isExist(UserName)) { userItem thisuser = userManager.GetAItem(UserName); if (userManager.check(UserName, pass)) { if (check) { AccountHelper.AddAccount(thisuser.UserName); } if (thisuser.Authority == 1) { Frame.Navigate(typeof(ServicePage), thisuser); } else { Frame.Navigate(typeof(userlistpage), thisuser); } } else { ErrorMessage.Text = "The password is incorrect"; } } else { ErrorMessage.Text = "The user does not exist"; } }
private async void RegisterButton_Click_Async(object sender, RoutedEventArgs e) { ErrorMessage.Text = ""; //In the real world you would normally validate the entered credentials and information before //allowing a user to register a new account. //For this sample though we will skip that step and just register an account if username is not null. if (!string.IsNullOrEmpty(UsernameTextBox.Text)) { if (PasswordTextBox.ToString().Equals(PasswordConfirmTextBox.ToString())) { //Register a new account _account = AccountHelper.AddAccount(UsernameTextBox.Text); //Register new account with Microsoft Passport await MicrosoftPassportHelper.CreatePassportKeyAsync(_account.Username); //Navigate to the Welcome Screen. Frame.Navigate(typeof(Welcome), _account); } else { MessageDialog showDialog = new MessageDialog("You have mistyped your password"); showDialog.Commands.Add(new UICommand("Okay") { Id = 0 }); showDialog.DefaultCommandIndex = 0; var result = await showDialog.ShowAsync(); } } else { ErrorMessage.Text = "Please enter a username"; } }
public HttpResponseMessage CreateAccount(RegistrationRequestModel account) { if (account == null) { return(ToolsBoxResponse.OK(new BasicResponseModel { Message = "Request is empty", Status = HttpStatusCode.BadRequest })); } if (!ToolsBox.IsEmailValid(account.email)) { return(ToolsBoxResponse.OK(new BasicResponseModel { Message = "email not valid", Status = HttpStatusCode.BadRequest })); } if (string.IsNullOrEmpty(account.password)) { return(ToolsBoxResponse.OK(new BasicResponseModel { Message = "No password provided", Status = HttpStatusCode.BadRequest })); } if (string.IsNullOrEmpty(account.username)) { return(ToolsBoxResponse.OK(new BasicResponseModel { Message = "No username provided", Status = HttpStatusCode.BadRequest })); } var response = AccountHelper.AddAccount(new DataProvider.Models.Account { email = account.email, password = account.password, username = account.username }); if (response == null) { return(ToolsBoxResponse.OK(new BasicResponseModel { Message = "Account can't be created, retry later.", Status = HttpStatusCode.InternalServerError })); } switch (response.Status) { case HttpStatusCode.OK: return(ToolsBoxResponse.OK(new RegistrationResponseModel { Token = TokenProvider.Generate(account.username, account.password), Id = response.Id, Status = HttpStatusCode.OK })); case HttpStatusCode.BadRequest: return(ToolsBoxResponse.OK(new BasicResponseModel { Message = response.Message, Status = HttpStatusCode.BadRequest })); default: return(ToolsBoxResponse.OK(new BasicResponseModel { Message = response.Message, Status = HttpStatusCode.InternalServerError })); } }
void SaveAccount() { bool addModelRole = false; Account act = new Account(); act.ID = IDLabel.Text; act.LoginName = NameTextBox.Text; act.LastName = LastNameTextBox.Text; act.Index = Convert.ToInt32(IndexTextBox.Text); act.State = Convert.ToInt32(UserStateDropDownList.SelectedValue); act.UserType = Convert.ToInt32(UserTypeDropDownList.SelectedValue); act.Description = DescriptionTextBox.Text; act.Email = EmailTextBox.Text; if (!String.IsNullOrEmpty(UserModelDropDownList.SelectedValue)) { if (File.Exists(ModelHelper.GetModelPath(UserModelDropDownList.SelectedValue))) { act.ModelName = UserModelDropDownList.SelectedValue; act.ModelConfig = ModelHelper.GetModelConfigXml(act.ModelName); act.ModelSchema = ModelHelper.GetModelSchema(act.ModelName); } else { throw new Exception(UserModelDropDownList.SelectedValue + " 模型配置文件没有找到!"); } } if (act.ModelState != 2 && ModelStateDropDownList.SelectedValue == "2" && !String.IsNullOrEmpty(UserModelDropDownList.SelectedValue)) { string moldelStr = UserModelDropDownList.SelectedValue; act.ModelState = Int32.Parse(ModelStateDropDownList.SelectedValue); addModelRole = true; if (SendMailCheckBox.Checked) { AccountMails.SendMailOfPassNotify(act, UserModelDropDownList.SelectedItem.Text, MailBodyTextBox.Text); } } if (DepartmentIDTextBox.Text != null && DepartmentIDTextBox.Text.Trim() != "") { act.DepartmentID = DepartmentIDTextBox.Text; act.Department = AccountHelper.GetDepartment(act.DepartmentID, new string[] { "Name" }).Name; } string chkEmail = CheckEmail(this.EmailTextBox.Text.Trim()); if (act.ID == String.Empty) { string checkName = CheckUserName(NameTextBox.Text); if (checkName == "" && chkEmail == "") { if (String.IsNullOrEmpty(PassWordText.Text) || String.IsNullOrEmpty(PassWordText.Text.Trim())) { Messages.ShowError("密码不能为空"); return; } act.DepartmentID = ParentTextBox.Text; act.IsPasswordHashed = IsHashedCheckBox.Checked; if (act.PasswordHashed == (int)We7.CMS.Common.Enum.TypeOfPasswordHashed.webEncrypt) { act.Password = Security.Encrypt(PassWordText.Text); } else if (act.PasswordHashed == (int)We7.CMS.Common.Enum.TypeOfPasswordHashed.bbsEncrypt) { act.Password = Security.BbsEncrypt(PassWordText.Text); } else { act.Password = PassWordText.Text; } if (SendMailCheckBox.Checked) { MailHelper mailHelper = AccountMails.GetMailHelper(); if (String.IsNullOrEmpty(mailHelper.AdminEmail)) { Messages.ShowError("没有配置管理员邮箱。如不需要发送邮箱,请去掉发送邮件选项。"); return; } if (String.IsNullOrEmpty(act.Email)) { Messages.ShowError("用户邮箱不能为空"); return; } } act = AccountHelper.AddAccount(act); ShowAccount(act); if (SendMailCheckBox.Checked) { AccountMails.SendMailOfRegister(act, PassWordText.Text, MailBodyTextBox.Text); } //记录日志 string content = string.Format("创建了帐户“{0}”", act.LoginName); AddLog("新建帐户", content); string rawurl = We7Helper.AddParamToUrl(Request.RawUrl, "saved", "1"); rawurl = We7Helper.AddParamToUrl(rawurl, "id", act.ID); Response.Redirect(rawurl); } else { Messages.ShowError("无法注册用户。原因:" + checkName + chkEmail); } } else { List <string> fields = new List <string>(); fields.Add("LoginName"); fields.Add("LastName"); fields.Add("MiddleName"); fields.Add("FirstName"); fields.Add("Index"); fields.Add("State"); fields.Add("UserType"); fields.Add("Description"); fields.Add("Email"); fields.Add("ModelName"); fields.Add("ModelState"); fields.Add("ModelConfig"); fields.Add("ModelSchema"); fields.Add("Overdue"); if (We7Utils.IsDateString(OverdueTextBox.Text)) { act.Overdue = DateTime.Parse(OverdueTextBox.Text); } if (DepartmentIDTextBox.Text != null && DepartmentIDTextBox.Text.Trim() != "") { fields.Add("DepartmentID"); fields.Add("Department"); } string repassword = ""; if (ResetPasswordCheckBox.Checked) { if (String.IsNullOrEmpty(PasswordTextBox.Text) || String.IsNullOrEmpty(PasswordTextBox.Text.Trim())) { Messages.ShowError("密码不能为空"); return; } fields.Add("PasswordHashed"); act.IsPasswordHashed = IsHashedCheckBox.Checked; if (act.PasswordHashed == (int)We7.CMS.Common.Enum.TypeOfPasswordHashed.webEncrypt) { act.Password = Security.Encrypt(PasswordTextBox.Text); } else if (act.PasswordHashed == (int)We7.CMS.Common.Enum.TypeOfPasswordHashed.bbsEncrypt) { act.Password = Security.BbsEncrypt(PasswordTextBox.Text); } else { act.Password = PasswordTextBox.Text; } repassword = PasswordTextBox.Text.Trim();//将密码临时保存在session中以便修改BBS数据库使用。 fields.Add("Password"); } AccountHelper.UpdateAccount(act, fields.ToArray()); if (addModelRole) { AddAccountModelRole(act); } Messages.ShowMessage("帐户信息已更新。"); //记录日志 string content = string.Format("更新了帐户“{0}”的信息", act.LoginName); AddLog("更新帐户", content); ResetPasswordCheckBox.Checked = false; } }
/// <summary> /// 注册 /// </summary> /// <param name="sender"></param> /// <param name="arg"></param> protected void bttnRegister_Onclick(object sender, EventArgs arg) { bttnRegisger.Enabled = false; StringBuilder checkResult = new StringBuilder(""); string validateCodeError = CheckValidateCode(); if (!string.IsNullOrEmpty(validateCodeError)) { checkResult.Append(validateCodeError + "<br/>"); } string emailError = CheckEmail(); if (!string.IsNullOrEmpty(emailError)) { checkResult.Append(emailError + "<br/>"); } string userNameError = CheckUserName(); if (!string.IsNullOrEmpty(userNameError)) { checkResult.Append(userNameError + "<br/>"); } string passwordError = CheckPWD(); if (!string.IsNullOrEmpty(passwordError)) { checkResult.Append(passwordError + "<br/>"); } string rePasswordError = CheckRePWD(); if (!string.IsNullOrEmpty(rePasswordError)) { checkResult.Append(rePasswordError + "<br/>"); } if (!string.IsNullOrEmpty(checkResult.ToString())) { lblMsg.Text = "<font color='red'>" + checkResult.ToString() + "</font>"; } else { string userName = txtUserName.Text.Trim(); string password = txtPassword.Text.Trim(); Account account = new Account(); account.LoginName = userName; account.Password = password; account.Email = txtEmail.Text.Trim(); account.EmailValidate = 0; account.Created = DateTime.Now; account.Updated = DateTime.Now; account.State = 0; account.UserType = 1; account.PasswordHashed = (int)We7.CMS.Common.Enum.TypeOfPasswordHashed.noneEncrypt; try { account = AccountHelper.AddAccount(account); if (IsMallUser) { } if (!string.IsNullOrEmpty(DefaultRole)) { Role role = AccountHelper.GetRoleBytitle(DefaultRole); if (role != null && !string.IsNullOrEmpty(account.ID)) { AccountHelper.AssignAccountRole(account.ID, role.ID); } } SendMail(account, "user"); string strAccountId = Request[We7.Model.Core.UI.Constants.FEID]; string url = We7Helper.AddParamToUrl(Request.RawUrl, We7.Model.Core.UI.Constants.FEID, account.ID); url = We7Helper.AddParamToUrl(url, "activeIndex", "1"); Response.Redirect(url); } catch (Exception ex) { lblMsg.Text = "<font color='red'>无法注册用户!原因:" + ex.Message + "</font>"; } } bttnRegisger.Enabled = true; }