mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-14 10:11:58 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
32
server/FSO.Server.Database/DA/EmailConfirmations/EmailConfirmation.cs
Executable file
32
server/FSO.Server.Database/DA/EmailConfirmations/EmailConfirmation.cs
Executable file
|
@ -0,0 +1,32 @@
|
|||
namespace FSO.Server.Database.DA.EmailConfirmation
|
||||
{
|
||||
/// <summary>
|
||||
/// EmailConfirmation model
|
||||
/// </summary>
|
||||
public class EmailConfirmation
|
||||
{
|
||||
/// <summary>
|
||||
/// Confirmation type. Can be an email confirmation or password
|
||||
/// reset confirmation.
|
||||
/// </summary>
|
||||
public ConfirmationType type { get; set; }
|
||||
/// <summary>
|
||||
/// The user email address.
|
||||
/// </summary>
|
||||
public string email { get; set; }
|
||||
/// <summary>
|
||||
/// Randomized token.
|
||||
/// </summary>
|
||||
public string token { get; set; }
|
||||
/// <summary>
|
||||
/// Timestamp when the confirmation token will expire.
|
||||
/// </summary>
|
||||
public uint expires { get; set; }
|
||||
}
|
||||
|
||||
public enum ConfirmationType
|
||||
{
|
||||
email = 1,
|
||||
password
|
||||
}
|
||||
}
|
10
server/FSO.Server.Database/DA/EmailConfirmations/IEmailConfirmations.cs
Executable file
10
server/FSO.Server.Database/DA/EmailConfirmations/IEmailConfirmations.cs
Executable file
|
@ -0,0 +1,10 @@
|
|||
namespace FSO.Server.Database.DA.EmailConfirmation
|
||||
{
|
||||
public interface IEmailConfirmations
|
||||
{
|
||||
string Create(EmailConfirmation confirm);
|
||||
EmailConfirmation GetByEmail(string email, ConfirmationType type);
|
||||
EmailConfirmation GetByToken(string token);
|
||||
void Remove(string token);
|
||||
}
|
||||
}
|
57
server/FSO.Server.Database/DA/EmailConfirmations/SqlEmailConfirmations.cs
Executable file
57
server/FSO.Server.Database/DA/EmailConfirmations/SqlEmailConfirmations.cs
Executable file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Dapper;
|
||||
using FSO.Server.Common;
|
||||
|
||||
namespace FSO.Server.Database.DA.EmailConfirmation
|
||||
{
|
||||
public class SqlEmailConfirmations : AbstractSqlDA, IEmailConfirmations
|
||||
{
|
||||
public SqlEmailConfirmations(ISqlContext context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EmailConfirmation GetByToken(string token)
|
||||
{
|
||||
var confirm = Context.Connection.Query<EmailConfirmation>("SELECT * FROM fso_email_confirm WHERE token = @token", new { token = token }).FirstOrDefault();
|
||||
|
||||
if(confirm==null) { return null; }
|
||||
|
||||
if(Epoch.Now > confirm.expires)
|
||||
{
|
||||
Remove(confirm.token);
|
||||
return null;
|
||||
}
|
||||
|
||||
return confirm;
|
||||
}
|
||||
|
||||
public EmailConfirmation GetByEmail(string email, ConfirmationType type)
|
||||
{
|
||||
var confirm = Context.Connection.Query<EmailConfirmation>("SELECT * FROM fso_email_confirm WHERE email = @email AND type = @type", new { email = email, type = type }).FirstOrDefault();
|
||||
|
||||
if (confirm == null) { return null; }
|
||||
|
||||
if (Epoch.Now > confirm.expires)
|
||||
{
|
||||
Remove(confirm.token);
|
||||
return null;
|
||||
}
|
||||
|
||||
return confirm;
|
||||
}
|
||||
|
||||
public string Create(EmailConfirmation confirm)
|
||||
{
|
||||
confirm.token = Guid.NewGuid().ToString().ToUpper();
|
||||
Context.Connection.Execute("INSERT INTO fso_email_confirm (type, email, token, expires) VALUES (@type, @email, @token, @expires)", confirm);
|
||||
return confirm.token;
|
||||
}
|
||||
|
||||
public void Remove(string token)
|
||||
{
|
||||
Context.Connection.Execute("DELETE FROM fso_email_confirm WHERE token = @token", new { token = token });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue