public bool Login(String loginName, String password, bool encryptedPassword) { if (ProjectID == null) { return(false); } if (IsLogged && defComparer.Equals(CurrentUser.LoginName, loginName)) { if (encryptedPassword) { var passwordHash = CryptographyUtil.ComputeMD5(CurrentUser.Password); if (defComparer.Equals(passwordHash, password)) { return(true); } } else if (CurrentUser.Password == password) { return(true); } } ResetInstanceData(); var token = UserManagementProxy.Login(loginName, password, encryptedPassword); var success = token != null; if (success) { var loginUser = UserManagementProxy.GetCurrentUser(token.Value); if (loginUser == null) { return(false); } var userGroups = UserManagementProxy.GetUserGroups(token.Value, loginUser.ID, ProjectID.Value); if (!loginUser.IsSuperAdmin && !IgnoreGroupMembership && (userGroups == null || userGroups.Count == 0)) { return(false); } currentToken = token; currentUser = loginUser; currentUserGroups = userGroups; SaveCurrentTokenCookies(); } LogEvent("LoginByName", loginName, password, token, success); return(success); }
public bool Login(Guid token) { if (ProjectID == null) { return(false); } if (!IsTokenValid(token)) { return(false); } if (CurrentToken == token) { return(true); } ResetInstanceData(); var loginUser = UserManagementProxy.GetCurrentUser(token); var success = loginUser != null; if (success) { var userGroups = UserManagementProxy.GetUserGroups(token, loginUser.ID, ProjectID.Value); if (!loginUser.IsSuperAdmin && !IgnoreGroupMembership && (userGroups == null || userGroups.Count == 0)) { return(false); } currentToken = token; currentUser = loginUser; currentUserGroups = userGroups; SaveCurrentTokenCookies(); } LogEvent("LoginByToken", loginUser, token, success); return(success); }