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:
parent
9137426942
commit
40d9c121e4
1 changed files with 3 additions and 3 deletions
|
@ -55,10 +55,10 @@ namespace Nibriboard
|
||||||
public override bool ShouldAcceptConnection(HttpRequest connectionRequest, HttpResponse connectionResponse)
|
public override bool ShouldAcceptConnection(HttpRequest connectionRequest, HttpResponse connectionResponse)
|
||||||
{
|
{
|
||||||
HttpBasicAuthCredentials credentials = connectionRequest.BasicAuthCredentials;
|
HttpBasicAuthCredentials credentials = connectionRequest.BasicAuthCredentials;
|
||||||
User user = NibriServer.AccountManager.GetByName(credentials.Username);
|
User user = NibriServer.AccountManager.GetByName(credentials != null ? credentials.Username : null);
|
||||||
if (user == null || user.CheckPassword(credentials.Password)) {
|
if (user == null || user.CheckPassword(credentials != null ? credentials.Password : null)) {
|
||||||
// Authentication failed!
|
// Authentication failed!
|
||||||
connectionResponse.ResponseCode = HttpResponseCode.Forbidden;
|
connectionResponse.RequireHttpBasicAuthentication("Nibriboard");
|
||||||
connectionResponse.ContentType = "text/plain";
|
connectionResponse.ContentType = "text/plain";
|
||||||
connectionResponse.SetBody("Error: Invalid username or password.");
|
connectionResponse.SetBody("Error: Invalid username or password.");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue