Skip to content

Commit

Permalink
[server] 동일한 계정의 다른 연결에 메시지//추방할 수 있도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
powerumc committed Aug 2, 2019
1 parent bea949e commit accbec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions server/Ntreev.Crema.ServiceHosts/Users/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,14 @@ private void UserContext_ItemsDeleted(object sender, Services.ItemsDeletedEventA

private void UserContext_MessageReceived(object sender, MessageEventArgs e)
{
var userID = this.authentication.ID;
var exceptionUserID = e.UserID;
var userToken = this.authentication.Token;
var exceptionUserToken = e.UserToken;
var signatureDate = e.SignatureDate;
var userIDs = e.Items.Select(item => item.ID).ToArray();
var message = e.Message;
var messageType = e.MessageType;

this.InvokeEvent(userID, exceptionUserID, () => this.Callback.OnMessageReceived(signatureDate, userIDs, message, messageType));
this.InvokeEvent(userToken, exceptionUserToken, () => this.Callback.OnMessageReceived(signatureDate, userIDs, message, messageType));
}

private void UserContext_UsersLoggedIn(object sender, Services.ItemsEventArgs<AuthenticationInfo> e)
Expand Down Expand Up @@ -435,12 +435,12 @@ private void UserContext_UsersLoggedOut(object sender, Services.ItemsEventArgs<A

private void UserContext_UsersKicked(object sender, ItemsEventArgs<IUser> e)
{
var userID = this.authentication.ID;
var exceptionUserID = e.UserID;
var userToken = this.authentication.Token;
var exceptionUserToken = e.UserToken;
var signatureDate = e.SignatureDate;
var userIDs = e.Items.Select(item => item.ID).ToArray();
var comments = e.MetaData as string[];
this.InvokeEvent(userID, exceptionUserID, () => this.Callback.OnUsersKicked(signatureDate, userIDs, comments));
this.InvokeEvent(userToken, exceptionUserToken, () => this.Callback.OnUsersKicked(signatureDate, userIDs, comments));
}

private void UserContext_UsersBanChanged(object sender, ItemsEventArgs<IUser> e)
Expand Down
6 changes: 3 additions & 3 deletions server/Ntreev.Crema.Services/Users/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Authentication Login(SecureString password)

}

Guid authenticationToken = GetAuthenticationToken();
var authenticationToken = GetAuthenticationToken();

var authentication = new Authentication(new UserAuthenticationProvider(this), authenticationToken);
this.Sign(authentication);
Expand Down Expand Up @@ -265,6 +265,8 @@ public void Kick(Authentication authentication, string comment)
this.Container.InvokeUserKick(authentication, this, comment);
foreach (var auth in this.Authentications.Values.ToArray())
{
if (auth.Authentication.Token == authentication.Token) continue;

auth.Authentication.InvokeExpiredEvent(authentication.ID, comment);
}
this.Authentications.Clear();
Expand Down Expand Up @@ -660,8 +662,6 @@ private void ValidateKick(Authentication authentication, string comment)
throw new PermissionDeniedException();
if (this.IsOnline == false)
throw new InvalidOperationException(Resources.Exception_OfflineUserCannotKicked);
if (authentication.ID == this.ID)
throw new PermissionDeniedException(Resources.Exception_CannotKickYourself);
}

private void Sign(Authentication authentication)
Expand Down

0 comments on commit accbec5

Please sign in to comment.