Modify Login-Register-System
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -22,39 +21,19 @@ namespace reallife_gamemode.Server.Events
|
||||
[Command("login")]
|
||||
public void CmdLogin(Client player)
|
||||
{
|
||||
player.Freeze(true);
|
||||
player.TriggerEvent("showLogin",player);
|
||||
}
|
||||
[RemoteEvent("OnPlayerRegister")]
|
||||
public void OnPlayerRegister(Client player, string password)
|
||||
{
|
||||
|
||||
|
||||
using (var loginContext = new Model.DatabaseContext())
|
||||
{
|
||||
var user = new Entities.User { Name = player.Name, SocialClubName = player.SocialClubName, Password = ComputeSha256Hash(password) };
|
||||
var user = new Entities.User { Name = player.Name, SocialClubName = player.SocialClubName, Password = NAPI.Util.GetHashSha256(password) };
|
||||
loginContext.Users.Add(user);
|
||||
loginContext.SaveChanges();
|
||||
}
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Registriert, GZ");
|
||||
player.TriggerEvent("registerSuccess");
|
||||
}
|
||||
|
||||
static string ComputeSha256Hash(string rawData)
|
||||
{
|
||||
// Create a SHA256
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
// ComputeHash - returns byte array
|
||||
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
|
||||
|
||||
// Convert byte array to a string
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
builder.Append(bytes[i].ToString("x2"));
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Services
|
||||
{
|
||||
class HashService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user