1
0
Fork 0

[server] Fix crashes in new user auth system

This commit is contained in:
Starbeamrainbowlabs 2018-01-10 11:55:13 +00:00
parent 9137426942
commit 40d9c121e4
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 3 additions and 3 deletions

View File

@ -55,10 +55,10 @@ namespace Nibriboard
public override bool ShouldAcceptConnection(HttpRequest connectionRequest, HttpResponse connectionResponse)
{
HttpBasicAuthCredentials credentials = connectionRequest.BasicAuthCredentials;
User user = NibriServer.AccountManager.GetByName(credentials.Username);
if (user == null || user.CheckPassword(credentials.Password)) {
User user = NibriServer.AccountManager.GetByName(credentials != null ? credentials.Username : null);
if (user == null || user.CheckPassword(credentials != null ? credentials.Password : null)) {
// Authentication failed!
connectionResponse.ResponseCode = HttpResponseCode.Forbidden;
connectionResponse.RequireHttpBasicAuthentication("Nibriboard");
connectionResponse.ContentType = "text/plain";
connectionResponse.SetBody("Error: Invalid username or password.");
return false;