@@ -90,33 +90,6 @@ public Map<String, Object> getverify(HttpServletRequest request) {
9090 @ GetMapping ({"/github" })
9191 @ ApiOperation ("gituhub第三方登录调用接口" )
9292 public Map <String , Object > githubcallback (HttpServletRequest request ) throws JsonProcessingException {
93- // Map<String, String> jwtmap = new HashMap();
94- // //获取code 和 state
95- // String code = request.getParameter("code");
96- // String state = request.getParameter("state");
97- // //获取github返回的信息
98- // JSONObject userInfo = githubService.getUserInfo(githubService.getAccessToken(code, state));
99- // //把返回的信息封装成对象
100- // UserInfo info = JSON.parseObject(userInfo.toString(), UserInfo.class);
101- // //根据githubid查询用户信息
102- // Account rest = accountService.queryByGitId(info.getId(), null);
103- // String token;
104- // //判断改github是否进行过绑定 未绑定则进行绑定,绑定则返回用户信息
105- // if (rest != null) {
106- // jwtmap.put("username", rest.getUsername());
107- // jwtmap.put("githubId", rest.getGithubId());
108- // //把githubId存入数据库中用来严重token是否过期
109- // stringRedisTemplate.opsForValue().set(rest.getGithubId(), rest.getGithubId(), 900L, TimeUnit.SECONDS);
110- // token = JWTUtils.getToken(jwtmap);
111- // log.info("该用户已绑定");
112- // return ResultMapUtils.ResultMapWithToken(true, 0, "返回token用于登录", token);
113- // } else {
114- // jwtmap.put("githubId", info.getId().toString());
115- // token = JWTUtils.getToken(jwtmap);
116- // log.info("该用户未绑定");
117- // //返回token 用来绑定第三方账号
118- // return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
119- // }
12093 log .info ("我进入了github第三方登录调用接口" );
12194 Map <String , Object > map = UserUtils .callback (request , githubService , accountService , "githubId" );
12295 return map ;
@@ -132,31 +105,6 @@ public Map<String, Object> githubcallback(HttpServletRequest request) throws Jso
132105 @ ApiOperation ("gitee第三方登录调用接口" )
133106 public Map <String , Object > giteeCallBack (HttpServletRequest request ) throws IOException {
134107 log .info ("我进入了gitee第三方登录调用接口" );
135- // Map<String, String> jwtmap = new HashMap();
136- // String code = request.getParameter("code");
137- // String state = request.getParameter("state");
138- // JSONObject userInfo = giteeService.getUserInfo(this.giteeService.getAccessToken(code, state));
139- // //把json转化为对象
140- // UserInfo info = JSON.parseObject(userInfo.toString(), UserInfo.class);
141- // //根据giteeid查询用户信息
142- // Account rest = accountService.queryByGitId(null, Integer.toString(info.getId()));
143- // String token;
144- // //判断该gitee是否进行过绑定 未绑定则进行绑定,绑定则返回用户信息
145- // if (rest != null) {
146- // jwtmap.put("username", rest.getUsername());
147- // jwtmap.put("giteeId", rest.getGiteeId());
148- // token = JWTUtils.getToken(jwtmap);
149- // //把giteeId存入数据库中用来严重token是否过期
150- // stringRedisTemplate.opsForValue().set(rest.getGiteeId(), rest.getGiteeId(), 900L, TimeUnit.SECONDS);
151- // log.info("该用户已绑定");
152- // return ResultMapUtils.ResultMapWithToken(true, 0, "返回token用于登录", token);
153- // } else {
154- // jwtmap.put("giteeId", Integer.toString(info.getId()));
155- // token = JWTUtils.getToken(jwtmap);
156- // log.info("该用户未绑定");
157- // //返回token 用来绑定第三方账号
158- // return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
159- // }
160108 Map <String , Object > map = UserUtils .callback (request , giteeService , accountService , "giteeId" );
161109 return map ;
162110 }
@@ -171,15 +119,43 @@ public Map<String, Object> giteeCallBack(HttpServletRequest request) throws IOEx
171119 @ PostMapping ("/sendPasswordEmail" )
172120 @ ApiOperation ("发送修改密码链接到邮箱" )
173121 public Map <String , Object > sendPasswordEmail (Account account ) {
174- log .info ("我进入了发送链接邮箱地址" );
175122 HashMap <String , String > map = new HashMap <>();
176- //判断用户名是否不为空
177123 map .put ("email" , account .getEmail ());
178124 String token = JWTUtils .getToken (map , 12 , 10 );
125+ log .info ("我进入了发送链接邮箱地址" );
126+ String url ="http://localhost:8080/resetPwd?token=" + token ;
127+ String template ="<!DOCTYPE html>" +
128+ "<html lang=\" zh-n\" >" +
129+ "<head><meta charset=\" UTF-8\" >" +
130+ "<meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0\" >" +
131+ "<meta http-equiv=\" X-UA-Compatible\" content=\" ie=edge\" >" +
132+ "<style>body{background:#1e1e1e;width:100%;}.flex{display:flex;}.flex-ai{align-items:center;}.flex-col{flex-direction:column;}.flex-jcc{justify-content:center;}" +
133+ "</style>" +
134+ "</head>" +
135+ "<body>" +
136+ "<div class=\" flex flex-jcc\" style=\" background:#1e1e1e;width:100%;height:100%;padding: 50px 15px 100px 15px;box-sizing:border-box;\" >" +
137+ "<div class=\" flex flex-ai flex-jcc\" ><img style=\" width: 60px\" src=\" http://images.lliiooiill.cn/logo.svg\" alt=\" JS Encoder\" >" +
138+ "<span style=\" color:#F8F8F8;font-weight:bold;font-size:24px;margin-left:15px\" >JS Encoder</span>" +
139+ "</div>" +
140+ "<div class=\" flex flex-col\" style=\" width:100%;color:#999999;font-size:14px;margin-top:40px\" >" +
141+ "<span>这是你的重置密码链接,有效期为10分钟,请尽快操作!</span>" +
142+ "<a style=\" margin-top:15px;color=#1890ff\" href=\" \" >" +url +"</ a>" +
143+ "</div>" +
144+ "<div style=\" width:100%;color:#999999;font-size:14px;margin-top:40px\" class=\" flex flex-col\" >" +
145+ "<span>非本人操作,请忽略此邮件!</span>" +
146+ "<span>此为系统邮件,请勿回复</span>" +
147+ "</div>" +
148+ "<hr style=\" width:100%;border-color:#777777\" >" +
149+ "<a href=\" https://www.lliiooiill.cn\" style=\" color:#999999;font-size:12px;margin-top:40px\" >JS Encoder</ a>" +
150+ "<span style=\" color:#999999;font-size:12px;margin-top:10px\" >JS Encoder 团队</span>" +
151+ "</div>" +
152+ "</div>" +
153+ "</body>" +
154+ "</html>" ;
179155 Mail mail = new Mail ();
180156 mail .setTo (account .getEmail ());
181157 mail .setSubject ("请点击以下链接进行密码修改" );
182- mail .setMailContent ("http://localhost:8080/resetPwd?token=" + token );
158+ mail .setMailContent (url );
183159 //发送修改密码链接
184160 boolean b = mailService .sendActiveMail (mail );
185161 //返回token令牌
@@ -211,7 +187,7 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
211187 account .setEmail (email );
212188 //更新密码
213189 Boolean update = accountService .update (account );
214- log .info ("修改:" + Boolean .toString (update ));
190+ log .info ("修改:" + Boolean .toString (update ));
215191 return ResultMapUtils .ResultMap (update , 0 , null );
216192 } else {
217193
@@ -239,11 +215,42 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
239215 @ GetMapping ({"/send" })
240216 @ ApiOperation ("发送邮箱验证码" )
241217 public Map <String , Object > sendEmail (String email ) {
218+ log .info ("发送邮箱验证码:" +email );
242219 String code = UserUtils .getCode ();
220+ String template = "" +
221+ "<!DOCTYPE html>" +
222+ "<html lang=\" zh-n\" >" +
223+ "<head>" +
224+ "<meta charset=\" UTF-8\" ><meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0\" >" +
225+ "<meta http-equiv=\" X-UA-Compatible\" content=\" ie=edge\" >" +
226+ "<style>" +
227+ "body{width:100%;}.flex{display:flex;}.flex-ai{align-items:center;}.flex-col{flex-direction:column;}.flex-jcc{justify-content:center;}" +
228+ "</style>" +
229+ "</head>" +
230+ "<body>" +
231+ "<div class=\" flex flex-jcc\" style=\" background:#1e1e1e;width:100%;height:100%;padding: 50px 15px 100px 15px;box-sizing:border-box;\" ><div style=\" width:450px;\" class=\" flex flex-col flex-ai\" >" +
232+ "<div class=\" flex flex-ai flex-jcc\" ><img style=\" width: 60px\" src=\" http://images.lliiooiill.cn/logo.png\" alt=\" JS Encoder\" >" +
233+ "<span style=\" color:#F8F8F8;font-weight:bold;font-size:24px;margin-left:15px\" >JS Encoder</span>" +
234+ "</div>" +
235+ "<div class=\" flex flex-col\" style=\" width:100%;color:#999999;font-size:14px;margin-top:40px\" >" +
236+ "<span>欢迎注册 JS Encoder!</span><span style=\" margin-top:10px\" >这是你的邮箱验证码,有效期为5分钟,请尽快注册!</span></div><div class=\" flex flex-jcc\" >" +
237+ "<span style=\" margin-top:30px;font-weight:bold;font-size:24px;background:#1a1a1a;color:#1890ff;padding:5px 15px;border-radius:5px\" >" + code + "</span>" +
238+ "</div>" +
239+ "<div style=\" width:100%;color:#999999;font-size:14px;margin-top:40px\" class=\" flex flex-col\" >" +
240+ "<span>非本人操作,请忽略此邮件!</span>" +
241+ "<span>此为系统邮件,请勿回复</span>" +
242+ "</div>" +
243+ "<hr style=\" width:100%;border-color:#777777\" >" +
244+ "<a href=\" \" style=\" color:#999999;font-size:12px;margin-top:40px\" >JS Encoder</a>" +
245+ "<span style=\" color:#999999;font-size:12px;margin-top:10px\" >JS Encoder 团队</span>" +
246+ "</div>" +
247+ "</div>" +
248+ "</body>" +
249+ "</html>" ;
243250 Mail mail = new Mail ();
244251 mail .setTo (email );
245252 mail .setSubject ("验证码" );
246- mail .setMailContent (code );
253+ mail .setMailContent (template );
247254 boolean bol = mailService .sendActiveMail (mail );
248255 //把验证码存储到redis中
249256 stringRedisTemplate .opsForValue ().set (email , code , 300L , TimeUnit .SECONDS );
0 commit comments