forked from raquelsa/AspNet.Identity.MySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserStore.PasswordStore.cs
49 lines (43 loc) · 1.45 KB
/
UserStore.PasswordStore.cs
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
using Microsoft.AspNet.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace AspNet.Identity.MySQL
{
public partial class UserStore<TUser, TRole> : IUserPasswordStore<TUser>
{
/// <summary>
/// Returns the PasswordHash for a given TUser
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public Task<string> GetPasswordHashAsync(TUser user)
{
string passwordHash = userTable.GetPasswordHash(user.Id);
return Task.FromResult<string>(passwordHash);
}
/// <summary>
/// Verifies if user has password
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public Task<bool> HasPasswordAsync(TUser user)
{
var hasPassword = !string.IsNullOrEmpty(userTable.GetPasswordHash(user.Id));
return Task.FromResult<bool>(Boolean.Parse(hasPassword.ToString()));
}
/// <summary>
/// Sets the password hash for a given TUser
/// </summary>
/// <param name="user"></param>
/// <param name="passwordHash"></param>
/// <returns></returns>
public Task SetPasswordHashAsync(TUser user, string passwordHash)
{
user.PasswordHash = passwordHash;
return Task.FromResult<Object>(null);
}
}
}