Online players as news?
This commit is contained in:
@ -39,6 +39,7 @@ namespace NightmareCoreWeb2.Pages
|
||||
c.AtLogin |= (Character.AtLoginOptions)action;
|
||||
}
|
||||
c.SetAtLogin();
|
||||
OnGet();
|
||||
|
||||
}
|
||||
public void OnGet()
|
||||
@ -46,10 +47,23 @@ namespace NightmareCoreWeb2.Pages
|
||||
|
||||
ViewData["Title"] = "Login";
|
||||
AuthToken = Request.Cookies["AuthToken"];
|
||||
Username = Request.Cookies["Username"];
|
||||
if (!string.IsNullOrEmpty(Username))
|
||||
if (!string.IsNullOrEmpty(AuthToken))
|
||||
{
|
||||
SetupAccount(Username);
|
||||
conn.Open();
|
||||
string sql = "select email from tokens.active_tokens where token=@token";
|
||||
MySqlCommand cmd = new MySqlCommand(sql, conn);
|
||||
cmd.Parameters.AddWithValue("token", AuthToken);
|
||||
MySqlDataReader rdr = cmd.ExecuteReader();
|
||||
string email = "";
|
||||
while (rdr.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
email = rdr.GetString(0);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
SetupAccount(email.Substring(0, email.IndexOf("@")));
|
||||
}
|
||||
}
|
||||
public void SetupAccount(string Username)
|
||||
@ -73,7 +87,6 @@ namespace NightmareCoreWeb2.Pages
|
||||
|
||||
public void OnPostLogin()
|
||||
{
|
||||
Console.WriteLine("Logging in!");
|
||||
UserEmail = Request.Form["UserEmail"];
|
||||
UserPassword = Request.Form["UserPassword"];
|
||||
Username = UserEmail.Substring(0, UserEmail.IndexOf("@"));
|
||||
@ -81,10 +94,10 @@ namespace NightmareCoreWeb2.Pages
|
||||
if (a.AuthenticateAccount(UserPassword))
|
||||
{
|
||||
Response.Cookies.Append("Username", Username);
|
||||
Response.Cookies.Append("AuthToken", a.Verifier);
|
||||
Response.Cookies.Append("AuthToken", UserPassword);
|
||||
Response.Redirect("/Account");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace NightmareCoreWeb2.Pages
|
||||
@ -110,5 +111,20 @@ namespace NightmareCoreWeb2.Pages
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ActionResult OnGetAlert() {
|
||||
string ret = "";
|
||||
if (this.OnlineCharacters.Count > 0) {
|
||||
ret += "SERVERALERT:\nOnline Characters:\n";
|
||||
|
||||
foreach (Character c in OnlineCharacters) {
|
||||
ret += $"{c.Username} as {c.Name}\n";
|
||||
}
|
||||
ret += "\n\r";
|
||||
}
|
||||
return Content(ret);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user