/// <summary> /// Performs the Login. /// </summary> /// <param name="account">Users account</param> /// <param name="password">Users password</param> /// <returns>true if the credentials are valid</returns> public static bool Login(string account, string password) { if (null == account) { throw new ArgumentException(Language.GetText("exception_NullReferenceParameter"), "account"); } Users u = Users; Users.UserRow user = u.User.FindBylogin(account.ToLower(CultureInfo.CurrentCulture)); if (user == null) { return(false); } if (user.password != password) { return(false); } // Add login to the statistics. LoginStatisticService service = (LoginStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(LoginStatisticService)); if (null != service) { service.AddLogin(HttpContext.Current, user.id); } FormsAuthentication.SetAuthCookie(account, false); return(true); }
/// <summary> /// Constructor of the LoginWorker class. /// </summary> /// <param name="context">Users HttpContext.</param> /// <param name="userId">ID of the user.</param> public LoginWorker(LoginStatisticService service, HttpContext context, Guid userId) : base(context) { this.service = service; this.userId = userId; this.lastLogin = DateTime.Now; }
private void LoadLoginData() { LoginStatisticService service = (LoginStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(LoginStatisticService)); LoginStatisticData data = service.GetData(Context); List <LoginEntry> entries = new List <LoginEntry>(); foreach (LoginStatisticData.TLoginRow row in data.TLogin.Rows) { Portal.API.Users.UserRow user = UserManagement.Users.FindById(row.UserId); LoginEntry entry = new LoginEntry(); if (null != user) { // User was found, so use the actual user infos to show. entry.Login = user.login; entry.FirstName = user.SafeFirstName; entry.LastName = user.SafeSurName; } else { // User was deleted, so use cached infos. entry.Login = row.Login; entry.FirstName = row.FirstName; entry.LastName = row.LastName; } entry.LoginCount = row.LoginCount; entry.LastLogin = row.LastLogin; entries.Add(entry); } repeaterLogin.DataSource = entries; repeaterLogin.DataBind(); }