File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/ServerPlatform/serverplatform Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,24 @@ public static void HandleRequest(HttpListenerContext context)
80
80
81
81
RespondHTML ( context , "<p>Server Platform Backend server</p><p>We recommend that you only port-forward the Frontend to prevent any intrusions.</p><br><p>Made with ❤️</p><p>© 2025 BastionSG</p>" ) ;
82
82
}
83
+ else if ( context . Request . HttpMethod == "POST" && context . Request . Url . AbsolutePath == "/auth" )
84
+ {
85
+ string requestBody = new System . IO . StreamReader ( context . Request . InputStream , context . Request . ContentEncoding ) . ReadToEnd ( ) ;
86
+ ConsoleLogging . LogMessage ( $ "User { JObject . Parse ( requestBody ) [ "username" ] } attempting to authenticate...", "Authentication" ) ;
87
+ string token = "" ;
88
+ try {
89
+ token = UserAuth . AuthenticateUser ( JObject . Parse ( requestBody ) [ "username" ] . ToString ( ) , JObject . Parse ( requestBody ) [ "password" ] . ToString ( ) ) ;
90
+ }
91
+ catch ( Exception ex )
92
+ {
93
+ token = ex . Message ;
94
+ }
95
+ finally
96
+ {
97
+ RespondText ( context , token ) ;
98
+ }
99
+
100
+ }
83
101
else
84
102
{
85
103
context . Response . StatusCode = 404 ;
You can’t perform that action at this time.
0 commit comments