mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
1、登录返回用户名
2、getGithubUrl 返回值修改为json 3、修改 未知错误,请联系管理员 为具体的错误信息
This commit is contained in:
parent
31efe5feff
commit
6aa704f5c0
@ -34,6 +34,7 @@ public class SecurityAuthenticationHandler implements AuthenticationSuccessHandl
|
||||
PrintWriter writer = httpServletResponse.getWriter();
|
||||
Map<String, String> token = new HashMap<>();
|
||||
token.put("token", at.getToken());
|
||||
token.put("username", at.getName());
|
||||
writer.write(gson.toJson(ResultUtil.success(token)) );
|
||||
writer.flush();
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.qyi.e5.controller.auth2;
|
||||
|
||||
import io.qyi.e5.bean.result.Result;
|
||||
import io.qyi.e5.github.mapper.GithubMapper;
|
||||
import io.qyi.e5.github.service.IGithubService;
|
||||
import io.qyi.e5.user.mapper.UserMapper;
|
||||
import io.qyi.e5.util.EncryptUtil;
|
||||
import io.qyi.e5.util.ResultUtil;
|
||||
import io.qyi.e5.util.redis.RedisUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -36,11 +38,10 @@ public class Auth {
|
||||
|
||||
|
||||
@RequestMapping("/getGithubUrl")
|
||||
public void getGithubUrl(HttpServletResponse response) {
|
||||
public Result getGithubUrl() {
|
||||
String state = EncryptUtil.getInstance().SHA1Hex(UUID.randomUUID().toString());
|
||||
redisUtil.set(states + state, true, 600);
|
||||
response.setStatus(302);
|
||||
response.setHeader("Location", "https://github.com/login/oauth/authorize?client_id=" + client_id + "&redirect_uri=https://e5.qyi.io/auth2/receive&state=" + state);
|
||||
return ResultUtil.success("https://github.com/login/oauth/authorize?client_id=" + client_id + "&redirect_uri=https://e5.qyi.io/auth2/receive&state=" + state);
|
||||
}
|
||||
|
||||
/* @RequestMapping("/receive")
|
||||
|
@ -60,7 +60,7 @@ public class AuthController {
|
||||
boolean authorization_code = outlookService.getTokenAndSave(code, outlook.getClientId(), outlook.getClientSecret(), "https://e5.qyi.io/outlook/auth2/receive"
|
||||
, "authorization_code");
|
||||
if (!authorization_code) {
|
||||
return ResultUtil.error(-3, "未知错误,请联系管理员~");
|
||||
return ResultUtil.error(-3, "clientId 或 clientSecret 填写错误!授权失败!");
|
||||
}
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
@ -60,17 +60,17 @@ public class OutlookController {
|
||||
}
|
||||
return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
@GetMapping("/getOutlookInfo")
|
||||
public Result getOutlookInfo(){
|
||||
public Result getOutlookInfo() {
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
int github_id = authentication.getGithub_id();
|
||||
QueryWrapper<Outlook> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("github_id", github_id);
|
||||
Outlook one = outlookService.getOne(queryWrapper);
|
||||
OutlookVo vo = new OutlookVo();
|
||||
System.out.println(one);
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one,vo);
|
||||
BeanUtils.copyProperties(one, vo);
|
||||
}
|
||||
return ResultUtil.success(vo);
|
||||
}
|
||||
|
@ -164,12 +164,27 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取邮件内容
|
||||
* @Description:
|
||||
* @param: count 读取数量,0 则读取当前页所有
|
||||
* @return: void
|
||||
* @Author: 落叶随风
|
||||
* @Date: 2020/4/15
|
||||
*/
|
||||
public void getMailBody(int count,String MailBody ,String access_token) throws Exception {
|
||||
Map<String, Object> head = new HashMap<>();
|
||||
head.put("Content-Type", "application/json");
|
||||
head.put("Authorization", access_token);
|
||||
String s = OkHttpRequestUtils.doGet("https://graph.microsoft.com/v1.0/me/messages/", head, null);
|
||||
}
|
||||
|
||||
public String MailList(String access_token) throws Exception {
|
||||
Map<String, Object> head = new HashMap<>();
|
||||
head.put("Content-Type", "application/json");
|
||||
head.put("Authorization", access_token);
|
||||
String s = OkHttpRequestUtils.doGet("https://graph.microsoft.com/v1.0/me/messages?$select=sender,subject", head, null);
|
||||
logger.info("请求邮件列表返回数据:" + s);
|
||||
logger.debug("请求邮件列表返回数据:" + s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user