You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
966 B
39 lines
966 B
using Models;
|
|
using Services;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using LocalServices.Data;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace LocalServices
|
|
{
|
|
internal class AuthService : IAuthService
|
|
{
|
|
private readonly IDatabase db;
|
|
|
|
|
|
public AuthService(IDatabase db)
|
|
{
|
|
this.db = db;
|
|
}
|
|
|
|
public Account? Login(string email, string password)
|
|
{
|
|
return db.GetAccount(email, password);
|
|
}
|
|
|
|
public Account? Register(string email, string username, string password)
|
|
{
|
|
if (email == null || username == null || password == null)
|
|
return null;
|
|
|
|
var userAccount = new Account(new User(Constants.DEFAULT_ACCOUNT_IMAGE, username, Guid.NewGuid()), email);
|
|
db.InsertAccount(userAccount, password);
|
|
return userAccount;
|
|
}
|
|
}
|
|
}
|