mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added udpating user LastSeen when setting the user's token's LastSeen
This commit is contained in:
parent
e6589638bd
commit
e3e5a60de7
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -341,6 +341,13 @@ namespace Teknik.Areas.Users.Utility
|
|||||||
User foundUser = GetUser(db, username);
|
User foundUser = GetUser(db, username);
|
||||||
if (foundUser != null)
|
if (foundUser != null)
|
||||||
{
|
{
|
||||||
|
// Update the user's last seen date
|
||||||
|
if (foundUser.LastSeen < lastUsed)
|
||||||
|
{
|
||||||
|
foundUser.LastSeen = lastUsed;
|
||||||
|
db.Entry(foundUser).State = EntityState.Modified;
|
||||||
|
}
|
||||||
|
|
||||||
string hashedToken = SHA256.Hash(token);
|
string hashedToken = SHA256.Hash(token);
|
||||||
List<AuthToken> tokens = foundUser.AuthTokens.Where(t => t.HashedToken == hashedToken).ToList();
|
List<AuthToken> tokens = foundUser.AuthTokens.Where(t => t.HashedToken == hashedToken).ToList();
|
||||||
if (tokens != null)
|
if (tokens != null)
|
||||||
@ -350,8 +357,8 @@ namespace Teknik.Areas.Users.Utility
|
|||||||
foundToken.LastDateUsed = lastUsed;
|
foundToken.LastDateUsed = lastUsed;
|
||||||
db.Entry(foundToken).State = EntityState.Modified;
|
db.Entry(foundToken).State = EntityState.Modified;
|
||||||
}
|
}
|
||||||
db.SaveChanges();
|
|
||||||
}
|
}
|
||||||
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user