1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[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

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;