Skip to content

Commit 20152ea

Browse files
committed
finish spring boot change password
1 parent 8f728db commit 20152ea

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CarzyCarSpringBootServer/src/main/java/com/tastsong/crazycar/controller/UserInfoController.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.tastsong.crazycar.controller;
22

3+
import javax.websocket.OnClose;
4+
import javax.xml.crypto.Data;
5+
36
import org.springframework.beans.factory.annotation.Autowired;
47
import org.springframework.context.annotation.Scope;
58
import org.springframework.web.bind.annotation.RequestMapping;
@@ -9,11 +12,13 @@
912
import com.tastsong.crazycar.common.ResultCode;
1013
import com.tastsong.crazycar.model.UserInfoModel;
1114
import com.tastsong.crazycar.service.LoginService;
15+
import com.tastsong.crazycar.Util.Util;
1216

1317
import cn.hutool.json.JSONObject;
1418

1519
import org.springframework.web.bind.annotation.PostMapping;
1620
import org.springframework.web.bind.annotation.RequestBody;
21+
import org.springframework.web.bind.annotation.RequestHeader;
1722

1823

1924
@RestController
@@ -33,4 +38,16 @@ public Object getUserInfo(@RequestBody JSONObject body) throws Exception {
3338
return Result.failure(ResultCode.RC404);
3439
}
3540
}
41+
42+
@PostMapping(value = "/ModifyPassword")
43+
public Object ModifyPassword(@RequestBody JSONObject body, @RequestHeader(Util.TOKEN) String token) throws Exception{
44+
Integer uid = Util.getUidByToken(token);
45+
String password = body.getStr("password");
46+
if(password.length() >= 6){
47+
loginService.changePassword(uid, password);
48+
return Result.success();
49+
} else {
50+
return Result.failure(ResultCode.RC423);
51+
}
52+
}
3653
}

CrazyCar/Assets/Scripts/System/NetworkSystem.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public IEnumerator POSTHTTP(string url, byte[] data = null, string token = null,
6161

6262
UnityWebRequest request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST);
6363
if (data != null) {
64-
request.uploadHandler = new UploadHandlerRaw(data);
64+
try {
65+
request.uploadHandler = new UploadHandlerRaw(data);
66+
} catch {
67+
Debug.LogError("PploadHandler : " + Encoding.UTF8.GetString(data));
68+
}
6569
}
6670
request.downloadHandler = new DownloadHandlerBuffer();
6771
request.SetRequestHeader("Content-Type", "application/json");

CrazyCar/Assets/Scripts/Utility/PathRecorderUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class RequestUrl {
1515
public static string buyTimeTrialClassUrl = "v2/BuyTimeTrialClass";
1616
public static string timeTrialResultUrl = "v2/TimeTrialResult";
1717
public static string timeTrialRankUrl = "v2/TimeTrialRank";
18-
public static string modifyPersonalInfoUrl = "v2/ModifyPersonalInfo";
18+
public static string modifyPersonalInfoUrl = "v2/UserInfo/ModifyPassword";
1919
public static string equipUrl = "v2/Equip/Detail";
2020
public static string buyEquipUrl = "v2/Equip/Buy";
2121
public static string changeEquipUrl = "v2/Equip/Change";

0 commit comments

Comments
 (0)