1
0
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:
Uncled1023 2018-01-06 21:32:37 -08:00
parent e6589638bd
commit e3e5a60de7

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
@ -341,6 +341,13 @@ namespace Teknik.Areas.Users.Utility
User foundUser = GetUser(db, username);
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);
List<AuthToken> tokens = foundUser.AuthTokens.Where(t => t.HashedToken == hashedToken).ToList();
if (tokens != null)
@ -350,8 +357,8 @@ namespace Teknik.Areas.Users.Utility
foundToken.LastDateUsed = lastUsed;
db.Entry(foundToken).State = EntityState.Modified;
}
db.SaveChanges();
}
db.SaveChanges();
}
}