-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCredentialRepository.cs
More file actions
50 lines (46 loc) · 1.27 KB
/
CredentialRepository.cs
File metadata and controls
50 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Developer_Allocation_Management
{
internal class CredentialRepository
{
public static Developer AuthenticateDataBase(String email)
{
try
{
using (Repository dbContext = new Repository())
{
return dbContext.Developers.Include("Credential").Where(d => d.Credential.Email == email).FirstOrDefault();
}
}
catch (Exception)
{
throw;
}
}
public static Developer Authenticate(String email, String password)
{
Developer developer = AuthenticateDataBase(email);
if (developer != null)
{
String passworddb = developer.Credential.Password;
if (passworddb == Credential.ComputeSHA256(password, Credential.SALT))
{
return developer;
}
else
{
return null;
}
}
else
{
return null;
}
}
}
}