@@ -118,8 +118,7 @@ public Map<String, Object> githubcallback(HttpServletRequest request) throws Jso
118118 // return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
119119 // }
120120 log .info ("我进入了github第三方登录调用接口" );
121- Map <String , Object > map = UserUtils .callback (request , githubService , stringRedisTemplate ,
122- accountService , "githubId" );
121+ Map <String , Object > map = UserUtils .callback (request , githubService , accountService , "githubId" );
123122 return map ;
124123 }
125124
@@ -158,8 +157,7 @@ public Map<String, Object> giteeCallBack(HttpServletRequest request) throws IOEx
158157 // //返回token 用来绑定第三方账号
159158 // return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
160159 // }
161- Map <String , Object > map = UserUtils .callback (request , giteeService , stringRedisTemplate ,
162- accountService , "giteeId" );
160+ Map <String , Object > map = UserUtils .callback (request , giteeService , accountService , "giteeId" );
163161 return map ;
164162 }
165163
@@ -177,7 +175,7 @@ public Map<String, Object> sendPasswordEmail(Account account) {
177175 HashMap <String , String > map = new HashMap <>();
178176 //判断用户名是否不为空
179177 map .put ("email" , account .getEmail ());
180- String token = JWTUtils .getToken (map );
178+ String token = JWTUtils .getToken (map , 12 , 10 );
181179 Mail mail = new Mail ();
182180 mail .setTo (account .getEmail ());
183181 mail .setSubject ("请点击以下链接进行密码修改" );
@@ -207,12 +205,19 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
207205 DecodedJWT verify = JWTUtils .verify (token );
208206 //获取用户名
209207 String email = verify .getClaim ("email" ).asString ();
210- account .setEmail (email );
211- //更新密码
212- accountService .update (account );
213- return ResultMapUtils .ResultMap (true , 0 , null );
208+ //验证token是否正确
209+ if (StringUtils .isNotBlank (email )) {
210+ account .setEmail (email );
211+ //更新密码
212+ Boolean update = accountService .update (account );
213+ return ResultMapUtils .ResultMap (true , 0 , null );
214+ } else {
215+
216+ }
217+ //token无效
218+ return ResultMapUtils .ResultMap (false , 0 , null );
214219 } catch (Exception e ) {
215- // e.printStackTrace();
220+ e .printStackTrace ();
216221 //token无效
217222 return ResultMapUtils .ResultMap (false , 0 , null );
218223 }
@@ -320,13 +325,8 @@ public Map<String, Object> doLogin(HttpServletRequest request) {
320325 DecodedJWT verify = JWTUtils .verify (token );
321326 //获取用户传输的第三方信息
322327 String username = verify .getClaim ("username" ).asString ();
323- String git = verify .getClaim ("git" ).asString ();
324- String gitId = null ;
325- if (StringUtils .isNotBlank (git )) {
326- gitId = stringRedisTemplate .opsForValue ().get (git );
327- }
328328 //判断令牌是否过期
329- if (StringUtils .isNotBlank (gitId )) {
329+ if (StringUtils .isNotBlank (username )) {
330330 Account account = accountService .queryByUsername (username );
331331 //(查询用户角色)s
332332 Role role = roleService .queryById (account .getRoleId ());
@@ -339,9 +339,9 @@ public Map<String, Object> doLogin(HttpServletRequest request) {
339339 SecurityContextHolder .getContext ().setAuthentication (auth );
340340 //生成登录token
341341 Map <String , String > tokenMap = new HashMap <>();
342- tokenMap .put ("username" ,account .getUsername ());
343- String resultToken = JWTUtils .getToken (tokenMap );
344- Map <String , Object > map = ResultMapUtils .ResultMapWithToken (true , 0 , account ,resultToken );
342+ tokenMap .put ("username" , account .getUsername ());
343+ String resultToken = JWTUtils .getToken (tokenMap , 10 , 24 );
344+ Map <String , Object > map = ResultMapUtils .ResultMapWithToken (true , 0 , account , resultToken );
345345 //存入用户信息
346346 request .getSession ().setAttribute ("map" , map );
347347 return map ;
@@ -359,8 +359,8 @@ public Map<String, Object> doLogin(HttpServletRequest request) {
359359
360360
361361 @ GetMapping ("/Test" )
362- public Map <String ,Object > Test (String username ){
362+ public Map <String , Object > Test (String username ) {
363363 Account account = accountService .queryByUsername (username );
364- return ResultMapUtils .ResultMap (true ,0 , account );
364+ return ResultMapUtils .ResultMap (true , 0 , account );
365365 }
366366}
0 commit comments