Skip to content

Commit

Permalink
Feature/3rd year (#236)
Browse files Browse the repository at this point in the history
* change get to post
  • Loading branch information
yuanmomo authored Apr 21, 2024
1 parent 7244598 commit 8412037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void twitterOauthLogin(@RequestParam(name = "test", defaultValue = "false
.toUriString());
}

@GetMapping("/oauth2/callback/discord")
@PostMapping("/oauth2/callback/discord")
public BaseResponse getTwitter(@RequestParam("code") String code, @RequestParam(required = false) String addressForTesting,
HttpSession session) {
// 检查用户是否注册
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

Expand Down Expand Up @@ -44,7 +44,7 @@ public void setUpTelegram() {
log.info("Successfully set up Telegram login validator");
}

@GetMapping("/oauth2/callback/telegram")
@PostMapping("/oauth2/callback/telegram")
public BaseResponse verifyTelegram(@RequestParam Map<String, String> params, @RequestParam(required = false) String addressForTesting,
HttpSession session) {
SessionUserInfo sessionUserInfo = HttpSessionUtils.getMember(session);
Expand All @@ -62,7 +62,9 @@ public BaseResponse verifyTelegram(@RequestParam Map<String, String> params, @Re
}

String telegramUserId = params.get("id");
String telegramUserName = params.get("username");
member.get().setTelegramUserId(telegramUserId);
member.get().setTelegramId(telegramUserName);
memberRepository.save(member.get());
return BaseResponse.success();
}
Expand Down

0 comments on commit 8412037

Please sign in to comment.