Addd code to remove duplicate FCM tokens
This commit is contained in:
parent
5ac1c2b798
commit
ca31c011e4
@ -225,6 +225,13 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
// Return a successful response with the generated tokens.
|
// Return a successful response with the generated tokens.
|
||||||
_logger.LogInfo("User {Username} logged in successfully.", user.UserName);
|
_logger.LogInfo("User {Username} logged in successfully.", user.UserName);
|
||||||
|
|
||||||
|
var existingFCMTokenMapping = await _context.FCMTokenMappings.Where(ft => ft.FcmToken == loginDto.FcmToken).ToListAsync();
|
||||||
|
|
||||||
|
if (existingFCMTokenMapping.Any())
|
||||||
|
{
|
||||||
|
_context.FCMTokenMappings.RemoveRange(existingFCMTokenMapping);
|
||||||
|
}
|
||||||
|
|
||||||
var fcmTokenMapping = new FCMTokenMapping
|
var fcmTokenMapping = new FCMTokenMapping
|
||||||
{
|
{
|
||||||
EmployeeId = emp.Id,
|
EmployeeId = emp.Id,
|
||||||
@ -349,6 +356,13 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(verifyMPIN.FcmToken))
|
if (!string.IsNullOrWhiteSpace(verifyMPIN.FcmToken))
|
||||||
{
|
{
|
||||||
|
var existingFCMTokenMapping = await _context.FCMTokenMappings.Where(ft => ft.FcmToken == verifyMPIN.FcmToken).ToListAsync();
|
||||||
|
|
||||||
|
if (existingFCMTokenMapping.Any())
|
||||||
|
{
|
||||||
|
_context.FCMTokenMappings.RemoveRange(existingFCMTokenMapping);
|
||||||
|
}
|
||||||
|
|
||||||
var fcmTokenMapping = new FCMTokenMapping
|
var fcmTokenMapping = new FCMTokenMapping
|
||||||
{
|
{
|
||||||
EmployeeId = requestEmployee.Id,
|
EmployeeId = requestEmployee.Id,
|
||||||
@ -943,6 +957,14 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
public async Task<IActionResult> StoreDeviceToken([FromBody] FCMTokenDto model)
|
public async Task<IActionResult> StoreDeviceToken([FromBody] FCMTokenDto model)
|
||||||
{
|
{
|
||||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
|
var existingFCMTokenMapping = await _context.FCMTokenMappings.Where(ft => ft.FcmToken == model.FcmToken).ToListAsync();
|
||||||
|
|
||||||
|
if (existingFCMTokenMapping.Any())
|
||||||
|
{
|
||||||
|
_context.FCMTokenMappings.RemoveRange(existingFCMTokenMapping);
|
||||||
|
}
|
||||||
|
|
||||||
var fcmTokenMapping = new FCMTokenMapping
|
var fcmTokenMapping = new FCMTokenMapping
|
||||||
{
|
{
|
||||||
EmployeeId = loggedInEmployee.Id,
|
EmployeeId = loggedInEmployee.Id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user