public async Task <BlogResponse <string> > GenerateTokenAsync(string type, string code, string state) { var response = new BlogResponse <string>(); if (!StateManager.IsExist(state)) { response.IsFailed("Request failed."); return(response); } StateManager.Remove(state); var token = type switch { "github" => GenerateToken(await _githubService.GetUserByOAuthAsync(type, code, state)), "gitee" => GenerateToken(await _giteeService.GetUserByOAuthAsync(type, code, state)), "alipay" => GenerateToken(await _alipayService.GetUserByOAuthAsync(type, code, state)), "dingtalk" => GenerateToken(await _dingtalkService.GetUserByOAuthAsync(type, code, state)), "microsoft" => GenerateToken(await _microsoftService.GetUserByOAuthAsync(type, code, state)), "weibo" => GenerateToken(await _weiboService.GetUserByOAuthAsync(type, code, state)), "qq" => GenerateToken(await _qqService.GetUserByOAuthAsync(type, code, state)), _ => throw new NotImplementedException($"Not implemented:{type}") }; response.IsSuccess(token); return(response); }
public async Task <IResponseOutput> GenerateTokenAsync(string type, string code, string state) { if (!StateManager.IsExist(state)) { return(ResponseOutput.NotOk("Request failed")); } StateManager.Remove(state); var token = type switch { "github" => GenerateToken(await _githubService.GetUserByOAuthAsync(type, code, state)), _ => throw new NotImplementedException($"Not implemented {type}") }; return(ResponseOutput.Ok(token)); }