/Source/Samples/Blog/Bifrost.Samples.Blog.Domain/Security/User.cs
C# | 52 lines | 41 code | 11 blank | 0 comment | 0 complexity | fa4b5316e5d12288caaae627f893ac7d MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- using System;
- using Bifrost.Domain;
- using Bifrost.Samples.Blog.Events.Security;
-
- namespace Bifrost.Samples.Blog.Domain.Security
- {
- public class User : AggregatedRoot
- {
- string _password;
-
- public User(Guid id) : base(id)
- {
- }
-
-
- public void Create(string userName)
- {
- Apply(new UserCreated(Id, userName, string.Empty));
- SetUserName(userName);
- }
-
- public void SetPassword(string password)
- {
- Apply(new PasswordSet(Id, password));
- }
-
- public void Login()
- {
- Apply(new LoginSuccessful(Id));
- }
-
-
- private void SetUserName(string userName)
- {
- Apply(new UserNameSet(Id, userName));
- }
-
- public void Handle(PasswordSet passwordSet)
- {
- _password = passwordSet.Password;
- }
-
- public void Handle(UserCreated userCreated)
- {
- _password = userCreated.Password;
- }
-
- public void Handle(UserNameSet userNameSet) {}
- public void Handle(LoginSuccessful loginSuccessful) {}
- public void Handle(LoginAttemptedWithWrongPassword loginAttemptedWithWrongPassword) {}
- }
- }