public async Task <IActionResult> LogOff(LogOffAddressModel model) { if (User.Identity.IsAuthenticated) { var user = await GetKahlaUser(); var device = await _dbContext .Devices .Where(t => t.UserId == user.Id) .SingleOrDefaultAsync(t => t.Id == model.DeviceId); await _signInManager.SignOutAsync(); if (device == null) { return(this.Protocol(ErrorType.Success, "Successfully logged you off, but we did not find device with id: " + model.DeviceId)); } else { _dbContext.Devices.Remove(device); await _dbContext.SaveChangesAsync(); return(this.Protocol(ErrorType.Success, "Success.")); } } else { return(this.Protocol(ErrorType.HasSuccessAlready, "You are not authorized at all. But you can still call this API.")); } }
public async Task <IActionResult> LogOff(LogOffAddressModel model) { if (User.Identity.IsAuthenticated) { var user = await GetKahlaUser(); var device = await _dbContext .Devices .Where(t => t.UserId == user.Id) .SingleOrDefaultAsync(t => t.Id == model.DeviceId); await _signInManager.SignOutAsync(); if (device == null) { return(this.Protocol(ErrorType.RequireAttention, "Successfully logged you off, but we did not find device with id: " + model.DeviceId)); } _dbContext.Devices.Remove(device); await _dbContext.SaveChangesAsync(); } else { await _signInManager.SignOutAsync(); } return(this.Protocol(ErrorType.Success, "Success.")); }