/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { if (Request.sessionCookie == null) { Response.error = Label.Get("error.authentication"); return(false); } ADO_readerOutput user = null; using (Login_BSO lBso = new Login_BSO()) { user = lBso.ReadBySession(Request.sessionCookie.Value); if (user.hasData) { if (user.data[0].CcnEmail == null) { DTO.CcnUsername = user.data[0].CcnUsername; ActiveDirectory_ADO adAdo = new ActiveDirectory_ADO(); ActiveDirectory_DTO adDto = adAdo.GetUser(Ado, DTO); if (adDto.CcnDisplayName != null) { user.data[0].CcnEmail = adDto.CcnEmail; } } Response.data = user.data; return(true); } else { Response.error = Label.Get("error.authentication"); return(false); } } }
protected override bool Execute() { if (Request.sessionCookie == null) { Response.error = Label.Get("error.authentication"); return(false); } Login_BSO lBso = new Login_BSO(Ado); var userResponse = lBso.ReadBySession(Request.sessionCookie.Value); if (userResponse.hasData) { string user = userResponse.data[0].CcnUsername; //This should not be allowed for an AD user DTO.CcnUsername = user; ActiveDirectory_ADO adAdo = new ActiveDirectory_ADO(); ActiveDirectory_DTO adDto = adAdo.GetUser(Ado, DTO); if (adDto.CcnDisplayName != null) { Response.data = JSONRPC.success; return(true); } string token = Utility.GetRandomSHA256(userResponse.data[0].CcnId.ToString()); if (lBso.Update1FaTokenForUser(userResponse.data[0].CcnUsername, token) != null) { SendEmail(new Login_DTO_Create() { CcnUsername = userResponse.data[0].CcnUsername, LngIsoCode = DTO.LngIsoCode, CcnEmail = userResponse.data[0].CcnEmail, CcnDisplayname = userResponse.data[0].CcnDisplayName }, token, "PxStat.Security.Login_API.Update1FA"); Response.data = JSONRPC.success; return(true); } return(false); } Response.error = Label.Get("error.authentication"); return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { Login_BSO lBso = new Login_BSO(Ado); ADO_readerOutput user; string displayName = null; string email = null; string ccnUsername = null; if (SamAccountName != null) { ActiveDirectory_ADO adAdo = new ActiveDirectory_ADO(); ActiveDirectory_DTO adDto = adAdo.GetUser(Ado, new Account_DTO_Create() { CcnUsername = SamAccountName }); displayName = adDto.CcnDisplayName; email = adDto.CcnEmail; ccnUsername = adDto.CcnUsername; } //Check if local access is available for AD users if (!Configuration_BSO.GetCustomConfig(ConfigType.global, "security.adOpenAccess") && ccnUsername != null) { Response.error = Label.Get("error.authentication"); return(false); } if (ccnUsername == null) { if (Request.sessionCookie == null) { Response.error = Label.Get("error.authentication"); return(false); } user = lBso.ReadBySession(Request.sessionCookie.Value); if (user.hasData) { if (user.data[0].CcnEmail.Equals(DBNull.Value) || user.data[0].CcnDisplayName.Equals(DBNull.Value)) { Response.data = JSONRPC.success; return(true); } displayName = user.data[0].CcnDisplayName; email = user.data[0].CcnEmail; ccnUsername = user.data[0].CcnUsername; } } if (ccnUsername == null) { Response.error = Label.Get("error.authentication"); return(false); } string token = Utility.GetRandomSHA256(ccnUsername); lBso.UpdateInvitationToken2Fa(ccnUsername, token); if (token != null) { SendEmail(new Login_DTO_Create() { CcnUsername = ccnUsername, LngIsoCode = DTO.LngIsoCode, CcnEmail = email, CcnDisplayname = displayName }, token, "PxStat.Security.Login_API.Update2FA"); Response.data = JSONRPC.success; return(true); } Response.error = Label.Get("error.create"); return(false); }