Last active
August 31, 2022 06:22
-
-
Save tac-ljustiniano/76d8930ee0b2d849fc8077fa8159b5b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccessUsers_Extension : PXGraphExtension<AccessUsers> | |
{ | |
... | |
protected virtual IEnumerable associateUser(PXAdapter adapter) | |
{ | |
Users user = (Users)Base.UserList.Current; // Acumatica user | |
if(GoogleActive && user != null) | |
{ | |
... | |
if (!string.IsNullOrEmpty(user.Email)) | |
{ | |
GoogleMaint socketGraph = PXGraph.CreateInstance<GoogleMaint>(); // My screen graph | |
GSocket gc = socketGraph.CreateGSocketInstance(); | |
if (gc != null) | |
{ | |
try | |
{ | |
UserData userItem = gc.GetUser(user.Email); | |
if (!string.IsNullOrEmpty(userItem?.ID)) | |
{ | |
user.IsApproved = userItem.Active; //Enable/Disable the user | |
user.AllowPasswordRecovery = false; // SSO does not require password recovery | |
user.PasswordChangeable = false; // SSO does not require allowing to change the password | |
user.PasswordNeverExpires = true; // Any password never expires | |
user.PasswordChangeOnNextLogin = false; // No need to change the password next login | |
Base.UserList.Update(user); | |
SetUserIdentity(userItem.ID); // Sets the Account ID | |
} | |
} | |
catch(Exception ex) | |
{ | |
// Error here | |
} | |
} | |
} | |
Base.Actions.PressSave(); | |
} | |
return adapter.Get(); | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
foreach (var uiRow in Base.Identities.Select()) | |
{ | |
UserIdentity ui = (UserIdentity)uiRow; | |
if (ui.ProviderName == Provider.Google) | |
{ | |
ui.UserKey = userKey; // Account ID | |
ui.Active = active; | |
Base.Identities.Update(ui); | |
break; | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment