mirror of https://github.com/icedream/npsharp.git
Fixing AuthenticationHelper fuckups (regex/http verb)
parent
24b5a93dda
commit
840ec4a64d
|
@ -66,18 +66,18 @@ namespace NPSharp.Authentication
|
|||
}.Uri;
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(uri);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/x-www-form-urlencoded";
|
||||
req.AllowAutoRedirect = true;
|
||||
using (var reqStream = req.GetRequestStream()) {
|
||||
var buffer = Encoding.UTF8.GetBytes (post);
|
||||
reqStream.Write (buffer, 0, post.Length);
|
||||
reqStream.Flush ();
|
||||
}
|
||||
req.Method = "POST";
|
||||
//req.ContentType = "application/x-www-urlencodedform";
|
||||
req.AllowAutoRedirect = true;
|
||||
|
||||
// Response will be in this syntax:
|
||||
// (ok|fail)#text#userid#username#email#sessiontoken
|
||||
var rx = new Regex ("^(?P<status>ok|fail)#(?P<text>.+)#(?P<userid>[0-9]+)#(?P<username>.+)#(?P<usermail>.+)#(?P<sessiontoken>.+)$");
|
||||
var rx = new Regex("^(?<status>ok|fail)#(?<text>.+)#(?<userid>[0-9]+)#(?<username>.+)#(?<usermail>.+)#(?<sessiontoken>.+)$");
|
||||
var resp = (HttpWebResponse)req.GetResponse ();
|
||||
using (var respStream = resp.GetResponseStream()) {
|
||||
using (var respReader = new StreamReader(respStream)) {
|
||||
|
|
|
@ -17,9 +17,13 @@ namespace NPSharp.CommandLine.MOTD
|
|||
{
|
||||
ah.Authenticate(username, password);
|
||||
}
|
||||
catch
|
||||
catch (Exception err)
|
||||
{
|
||||
Console.Error.WriteLine("Could not authenticate.");
|
||||
#if DEBUG
|
||||
Console.Error.WriteLine("Could not authenticate: {0}", err);
|
||||
#else
|
||||
Console.Error.WriteLine("Could not authenticate: {0}", err.Message);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue