mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
back to corehelpers
This commit is contained in:
@ -476,5 +476,30 @@ namespace Bit.Core.Utilities
|
||||
{
|
||||
return string.Concat("Custom_", type.ToString());
|
||||
}
|
||||
|
||||
public static bool UserInviteTokenIsValid(IDataProtector protector, string token, string userEmail, Guid orgUserId,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
var invalid = true;
|
||||
try
|
||||
{
|
||||
var unprotectedData = protector.Unprotect(token);
|
||||
var dataParts = unprotectedData.Split(' ');
|
||||
if(dataParts.Length == 4 && dataParts[0] == "OrganizationUserInvite" &&
|
||||
new Guid(dataParts[1]) == orgUserId &&
|
||||
dataParts[2].Equals(userEmail, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var creationTime = FromEpocMilliseconds(Convert.ToInt64(dataParts[3]));
|
||||
var expTime = creationTime.AddHours(globalSettings.OrganizationInviteExpirationHours);
|
||||
invalid = expTime < DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
return !invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user