-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Сервер: AES, авторизация, регестрация, токены
- Loading branch information
Showing
13 changed files
with
283 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace LauncherDM.Services.Interfaces | ||
{ | ||
internal interface ISignUpService | ||
{ | ||
bool SignUp(string login, string email, string password); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using LauncherDM.Properties; | ||
using LauncherDM.Services.Interfaces; | ||
using ServerTCP; | ||
using System.Text; | ||
using System; | ||
using System.Security.Cryptography; | ||
|
||
namespace LauncherDM.Services | ||
{ | ||
internal class SignUpService : ISignUpService | ||
{ | ||
private IServerRequestService _serverRequest; | ||
public bool SignUp(string login, string email, string password) | ||
{ | ||
if (string.IsNullOrEmpty(login)) | ||
throw new ArgumentNullException(login); | ||
|
||
if (string.IsNullOrEmpty(email)) | ||
throw new ArgumentNullException(email); | ||
|
||
if (string.IsNullOrEmpty(password)) | ||
throw new ArgumentNullException(password); | ||
|
||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(password)); | ||
var convertHash = Convert.ToHexString(hash); | ||
var data = string.Concat(login, ",", convertHash, ",", email); | ||
var requestToken = _serverRequest.SendMessageRequest(data, MessageHeader.MessageType.Registration); | ||
|
||
if (requestToken?.Message.ToString() == "0") | ||
return false; | ||
|
||
SettingsApp.Default.Token = requestToken?.Message.ToString(); | ||
SettingsApp.Default.Save(); | ||
return true; | ||
} | ||
|
||
public SignUpService() | ||
{ | ||
_serverRequest = new ServerRequestService(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.