- Timestamp:
- Mar 28, 2023, 5:40:08 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/UrlHandlers/SessionHandler.cs
r417 r422 61 61 private void HandleUserPassLogin (RequestContext _context, string _remoteEndpointString) { 62 62 if (!_context.Request.HasEntityBody) { 63 _context.Response.Redirect (pageErrorPath + "NoLoginData");63 WebUtils.WriteText (_context.Response, "NoLoginData", HttpStatusCode.BadRequest); 64 64 return; 65 65 } … … 76 76 Log.Error ("Error deserializing JSON from user/password login:"); 77 77 Log.Exception (e); 78 _context.Response.Redirect (pageErrorPath + "InvalidLoginJson");78 WebUtils.WriteText (_context.Response, "InvalidLoginJson", HttpStatusCode.BadRequest); 79 79 return; 80 80 } 81 81 82 82 if (!inputJson.TryGetValue ("username", out object fieldNode) || fieldNode is not string username) { 83 _context.Response.Redirect (pageErrorPath + "InvalidLoginJson");83 WebUtils.WriteText (_context.Response, "InvalidLoginJson", HttpStatusCode.BadRequest); 84 84 return; 85 85 } 86 86 87 87 if (!inputJson.TryGetValue ("password", out fieldNode) || fieldNode is not string password) { 88 _context.Response.Redirect (pageErrorPath + "InvalidLoginJson");88 WebUtils.WriteText (_context.Response, "InvalidLoginJson", HttpStatusCode.BadRequest); 89 89 return; 90 90 } … … 94 94 if (!webUser.HasValue) { 95 95 Log.Out ($"[Web] User/pass login failed from {_remoteEndpointString}"); 96 _context.Response.Redirect (pageErrorPath + "UserPassInvalid");96 WebUtils.WriteText (_context.Response, "UserPassInvalid", HttpStatusCode.Unauthorized); 97 97 return; 98 98 } … … 144 144 145 145 public static void HandleUserIdLogin (ConnectionHandler _connectionHandler, RequestContext _context, string _remoteEndpointString, 146 string _loginName, string _errorPage, string _username, PlatformUserIdentifierAbs _userId, PlatformUserIdentifierAbs _crossUserId = null, bool _ redirect= true) {146 string _loginName, string _errorPage, string _username, PlatformUserIdentifierAbs _userId, PlatformUserIdentifierAbs _crossUserId = null, bool _sendResponse = true) { 147 147 try { 148 148 WebConnection con = _connectionHandler.LogIn (_context.Request.RemoteEndPoint!.Address, _username, _userId, _crossUserId); … … 165 165 _context.Response.AppendCookie (cookie); 166 166 167 if (_ redirect) {168 _context.Response.Redirect (pageBasePath);167 if (_sendResponse) { 168 WebUtils.WriteText (_context.Response, ""); 169 169 } 170 170 } catch (Exception e) { 171 171 Log.Error ($"[Web] Error during {_loginName} login:"); 172 172 Log.Exception (e); 173 if (_ redirect) {174 _context.Response.Redirect (pageErrorPath + _errorPage);173 if (_sendResponse) { 174 WebUtils.WriteText (_context.Response, "LoginError", HttpStatusCode.InternalServerError); 175 175 } 176 176 }
Note:
See TracChangeset
for help on using the changeset viewer.