protected void btnLogin_Click(object sender, EventArgs e) { bool retval = false; CredentialService.CredentialSoapClient creds = new InsuranceCo.CredentialService.CredentialSoapClient(); CredentialService.LoginResult lr = null; string apiLogin = ""; if (txtEmail.Text.Length == 0 || txtPassword.Text.Length == 0) { setLoginErrorMessage("Please enter an email and a password"); } else { if (base.SettingIsSet("IntegratorsKey")) { apiLogin = "******" + System.Configuration.ConfigurationManager.AppSettings["IntegratorsKey"] + "]"; } else { setLoginErrorMessage("You must use an integrator's key!"); return; } apiLogin += txtEmail.Text; try { lr = creds.Login(apiLogin, txtPassword.Text); } catch (Exception excp) { setLoginErrorMessage("Exception: " + excp.Message); } } switch (lr.ErrorCode) { case CredentialService.ErrorCode.User_Does_Not_Exist_In_System: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Account_Lacks_Permissions: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.User_Lacks_Permissions: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.User_Authentication_Failed: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Unspecified_Error: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Success: Session["LoggedIn"] = true; Session["Email"] = txtEmail.Text; Session["APILogin"] = apiLogin; Session["Password"] = txtPassword.Text; Session["AccountID"] = lr.Accounts[0].AccountID; Session["AccountName"] = lr.Accounts[0].AccountName; Session["UserName"] = lr.Accounts[0].UserName; Session["UserID"] = lr.Accounts[0].UserID; // check accounts for Template CredentialService.Account[] accounts = checkAccountsForTemplatePermissions(lr); if (accounts.Length > 0) { Session["Accounts"] = accounts; // more than one account setup for account select if (accounts.Length > 1) { btnChangeAccount.Visible = true; foreach (CredentialService.Account account in accounts) { ddlAccountSelect.Items.Add(new ListItem(account.AccountName, account.AccountID)); } } else { btnChangeAccount.Visible = false; } retval = true; } else { retval = false; clearSessionVars(); setLoginErrorMessage("None of your accounts have Manage Template permissions. You can correct this in the Member Console"); } break; default: break; } if (retval == true) { pnlEnterLogin.Visible = false; pnlLoggedIn.Visible = true; pnlDisplayAccount.Visible = true; pnlChangeAccount.Visible = false; pnlManageTemplate.Visible = true; lblEmail.Text = (string)Session["Email"]; lblAccountName.Text = (string)Session["AccountName"]; if (checkAccountForTemplate() == true) { pnlTemplateExists.Visible = true; pnlTemplateUpload.Visible = false; } else { pnlTemplateUpload.Visible = true; pnlTemplateExists.Visible = false; } } }
protected void btnLogin_Click(object sender, EventArgs e) { bool retval = false; CredentialService.CredentialSoapClient creds = new InsuranceCo.CredentialService.CredentialSoapClient(); CredentialService.LoginResult lr = null; string apiLogin = ""; if (txtEmail.Text.Length == 0 || txtPassword.Text.Length == 0) { setLoginErrorMessage("Please enter an email and a password"); } else { // an integrators key is an optional part of the api login that allows users without explicit api permissions to use // api functions. An integrators key is provided to the integrator, not to the end users. Do not let end uses get access // to the integrators key. if (base.SettingIsSet("IntegratorsKey")) { apiLogin = "******" + System.Configuration.ConfigurationManager.AppSettings["IntegratorsKey"] + "]"; } apiLogin += txtEmail.Text; try { lr = creds.Login(apiLogin, txtPassword.Text); } catch (Exception excp) { setLoginErrorMessage("Exception: " + excp.Message); } } switch (lr.ErrorCode) { case CredentialService.ErrorCode.User_Does_Not_Exist_In_System: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Account_Lacks_Permissions: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.User_Lacks_Permissions: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.User_Authentication_Failed: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Unspecified_Error: retval = false; setLoginErrorMessage(lr.AuthenticationMessage); break; case CredentialService.ErrorCode.Success: Session["LoggedIn"] = true; Session["Email"] = txtEmail.Text; Session["APILogin"] = apiLogin; Session["Password"] = txtPassword.Text; Session["AccountID"] = lr.Accounts[0].AccountID; Session["AccountName"] = lr.Accounts[0].AccountName; Session["UserName"] = lr.Accounts[0].UserName; Session["UserID"] = lr.Accounts[0].UserID; // check accounts for Template CredentialService.Account[] accounts = checkAccountsForTemplatePermissions(lr); if(accounts.Length > 0){ Session["Accounts"] = accounts; // more than one account setup for account select if (accounts.Length > 1) { btnChangeAccount.Visible = true; foreach (CredentialService.Account account in accounts) { ddlAccountSelect.Items.Add(new ListItem(account.AccountName, account.AccountID)); } } else { btnChangeAccount.Visible = false; } retval = true; } else { retval = false; clearSessionVars(); setLoginErrorMessage("None of your accounts have Manage Template permissions. You can correct this in the Member Console"); } break; default: break; } if (retval==true){ pnlEnterLogin.Visible = false; pnlLoggedIn.Visible = true; pnlDisplayAccount.Visible = true; pnlChangeAccount.Visible=false; pnlManageTemplate.Visible = true; lblEmail.Text = (string) Session["Email"]; lblAccountName.Text = (string) Session["AccountName"]; if (checkAccountForTemplate() == true) { pnlTemplateExists.Visible = true; pnlTemplateUpload.Visible = false; } else { pnlTemplateUpload.Visible = true; pnlTemplateExists.Visible = false; } } }