/// <summary> /// JWT. Освежить. /// </summary> /// <param name="input">Ввод.</param> /// <returns>Задача с выводом.</returns> public async Task <ModAuthBaseCommonJobLoginJwtOutput> JwtRefresh(ModAuthBaseJobRefreshJwtInput input) { ModAuthBaseCommonJobLoginJwtOutput result = null; var userId = JwtService.GetUserIdByRefreshToken(input.DataToken); if (userId.CoreBaseExtConvertToNumericInt64() > 0) { var userManager = input.UserManager; var data = await userManager.FindByIdAsync(userId) .CoreBaseExtTaskWithCurrentCulture(false); if (data != null) { result = await data.ModAuthBaseExtCreateHostBasePartAuthJobLoginJwtOutput( userManager, JwtService ); } JwtService.RemoveRefreshToken(input.DataToken); } if (result == null) { throw new ModAuthBaseJobRefreshJwtException(); } return(result); }
public async Task <IActionResult> Refresh([FromBody] ModAuthBaseJobRefreshJwtInput input) { var result = new ModAuthBaseCommonJobLoginJwtResult(); var(execute, onSuccess, onError) = MyModel.BuildActionRefresh(input); try { result.Data = await execute().CoreBaseExtTaskWithCurrentCulture(false); onSuccess(result); } catch (Exception ex) { onError(ex, result); } return(Ok(result)); }
) BuildActionRefresh(ModAuthBaseJobRefreshJwtInput input) { input.UserManager = ExtUserManager; var job = AppJobRefresh; Task <ModAuthBaseCommonJobLoginJwtOutput> execute() => job.Execute(input); void onSuccess(ModAuthBaseCommonJobLoginJwtResult result) { job.OnSuccess(ExtLogger, result, input); } void onError(Exception ex, ModAuthBaseCommonJobLoginJwtResult result) { job.OnError(ex, ExtLogger, result); } return(execute, onSuccess, onError); }