protected void ButtonSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { DR_Accounts record = new DR_Accounts(); record._Username = TextBoxUserName.Text; record.QueryRow(); if (record.Cells["ID"].Data != null) { if (SecurityEncryption.VerifyCode(TextBoxPassword.Text, record._PCode)) { //Successful login DR_OpenIDMap openidrec = new DR_OpenIDMap(); openidrec._AccountID = record.ID; openidrec._OpenIdentifier = zContext.Session.OpenIDAuthenticationInformation.OpenIdentifier; openidrec.SaveChanges(); int records = 1; //refactor if (records > 0) { TextBoxResult.Text = "Successfully linked accounts!"; zContext.Session.Flags.OpenIDNotLinked = false; zContext.Session.ProcessLogin(); Response.Redirect("~/home"); } } else { TextBoxResult.Text = "Invalid Password."; } } else { TextBoxResult.Text = "Username not found."; } } }
public static DR_Accounts ResolveFromOpenID(string openIdentifier) { DR_Accounts account = new DR_Accounts(openIdentifier); return DR_Accounts.Get(account); }
private void LoadCurrentUserInfo(AuthenticationInformation info) { currentAccount = DR_Accounts.ResolveFromOpenID(info.OpenIdentifier); }
//Needs refactor internal void ResetData() { currentAccount = null; requests = new RequestContextTable(); //RefreshSessionObjects(); if (flags == null) flags = new SessionStateFlags(); if (OpenIDAuthenticationInformation != null) LoadCurrentUserInfo(OpenIDAuthenticationInformation); }
internal void ProcessLogin() { if (requests == null) requests = new RequestContextTable(); if (flags == null) flags = new SessionStateFlags(); if (OpenIDAuthenticationInformation != null) currentAccount = DR_Accounts.ResolveFromOpenID(OpenIDAuthenticationInformation.OpenIdentifier); }
internal void BeginProcessLogin(DR_Accounts currentAccount) { if (currentAccount != null && ZoliloCache.Instance.Accounts.ContainsKey(currentAccount.ID)) { this.currentAccount = currentAccount; ProcessLogin(); } else throw new ZoliloWebException("Login error"); }
void loginControl_LoginAccepted(DR_Accounts account) { ZoliloSession.Current.BeginProcessLogin(account); WebDirector.Instance.Redirect("/browse"); }
/// <summary> /// OVERRIDDEN -- Translates Form Abstraction Layer to Data Abstraction Layer /// </summary> /// <returns></returns> internal override DataRecord GenerateNewDataRecord() { DR_Accounts record = new DR_Accounts(); record._Username = username; record._PCode = SecurityEncryption.ComputeHash(password); record._Email = email; return record; }
/// <summary> /// Use this constructor to set up the parameters and the validation /// </summary> internal AccountRegistrationFormParameters( string username, string password, string confirmpassword, string email) : base() { this.username = username; this.password = password; this.confirmpassword = confirmpassword; this.email = email; Regex regexusername = new Regex(@"^[0-9a-zA-Z]{3,30}$"); Regex regexpassword = new Regex(@"^.{8,30}$"); Regex regexemail = new Regex(@"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"); if (password != confirmpassword) throw new SecurityValidationException(""); if (regexusername.Matches(username).Count == 0) throw new SecurityValidationException(""); if (regexpassword.Matches(password).Count == 0) throw new SecurityValidationException(""); if (regexemail.Matches(email).Count == 0) throw new SecurityValidationException(""); newRecord = (DR_Accounts)GenerateNewDataRecord(); }
void AccountLoginControl_D_LoginAccepted(DR_Accounts account) { }