2011-02-09 00:05:32 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Portoa.Logging;
|
|
|
|
|
using Portoa.Persistence;
|
|
|
|
|
using Portoa.Security;
|
|
|
|
|
|
|
|
|
|
namespace VideoGameQuotes.Api {
|
|
|
|
|
public class User : Entity<User, int>, IPasswordProtected {
|
|
|
|
|
private readonly IPasswordProtected passwordProtector = new NullAllowingPasswordProtector();
|
|
|
|
|
|
2011-02-09 03:41:35 +00:00
|
|
|
|
public User() {
|
|
|
|
|
Created = DateTime.UtcNow;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-09 00:05:32 +00:00
|
|
|
|
public virtual DateTime Created { get; set; }
|
|
|
|
|
public virtual string Username { get; set; }
|
2011-02-10 21:04:13 +00:00
|
|
|
|
public virtual string IpAddress { get; set; }
|
2011-02-09 00:05:32 +00:00
|
|
|
|
public virtual UserGroup Group { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual void ChangePassword([DoNotLog]string newPassword) {
|
|
|
|
|
passwordProtector.ChangePassword(newPassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool VerifyPassword([DoNotLog]string potentialPassword) {
|
|
|
|
|
return passwordProtector.VerifyPassword(potentialPassword);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-21 23:59:06 +00:00
|
|
|
|
|
|
|
|
|
public static class UserExtensions {
|
|
|
|
|
public static string GetUsernameOrIp(this User user) {
|
|
|
|
|
return user.Username ?? user.IpAddress;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-09 00:05:32 +00:00
|
|
|
|
}
|