mirror of https://github.com/hykilpikonna/AquaDX
[O] Check username
parent
e799b48877
commit
f728b6ab1b
|
@ -1,6 +1,7 @@
|
|||
package icu.samnyan.aqua.sega.maimai2
|
||||
|
||||
import ext.API
|
||||
import ext.popAll
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.*
|
||||
import org.slf4j.LoggerFactory
|
||||
|
@ -22,7 +23,6 @@ class Maimai2ServletController(
|
|||
val getTransferFriend: GetTransferFriendHandler,
|
||||
val getUserActivity: GetUserActivityHandler,
|
||||
val userLogin: UserLoginHandler,
|
||||
val userLogout: UserLogoutHandler,
|
||||
val getUserData: GetUserDataHandler,
|
||||
val upsertUserAll: UpsertUserAllHandler,
|
||||
val getUserPreview: GetUserPreviewHandler,
|
||||
|
@ -62,7 +62,8 @@ class Maimai2ServletController(
|
|||
val createToken = BaseHandler { """{"Bearer":"AQUATOKEN"}""" }
|
||||
val cmUpsertUserPrintLog = BaseHandler { """{"returnCode":1,"orderId":"0","serialId":"FAKECARDIMAG12345678"}""" }
|
||||
|
||||
val endpointList = listOf("GetGameEventApi", "GetGameRankingApi", "GetGameSettingApi", "GetGameTournamentInfoApi",
|
||||
val endpointList = mutableListOf("GetGameEventApi", "GetGameRankingApi", "GetGameSettingApi",
|
||||
"GetGameTournamentInfoApi",
|
||||
"GetTransferFriendApi", "GetUserActivityApi", "GetUserCardApi", "GetUserCharacterApi", "GetUserDataApi",
|
||||
"GetUserExtendApi", "GetUserFavoriteApi", "GetUserGhostApi", "GetUserItemApi", "GetUserLoginBonusApi",
|
||||
"GetUserMapApi", "GetUserMusicApi", "GetUserOptionApi", "GetUserPortraitApi", "GetUserPreviewApi",
|
||||
|
@ -72,12 +73,15 @@ class Maimai2ServletController(
|
|||
"GetUserRecommendRateMusicApi", "GetUserRecommendSelectMusicApi", "CMGetSellingCardApi",
|
||||
"CMGetUserCardApi", "CMGetUserCardPrintErrorApi", "CMGetUserCharacterApi", "CMGetUserDataApi", "CMGetUserItemApi",
|
||||
"CMGetUserPreviewApi", "CMUpsertUserPrintApi",
|
||||
"CMUpsertUserPrintlogApi", "GetUserFavoriteItemApi", "GetUserRivalDataApi", "GetUserRivalMusicApi")
|
||||
|
||||
val noopEndpoint = setOf("GetUserScoreRankingApi", "UpsertClientBookkeepingApi", "UpsertClientSettingApi",
|
||||
"CMUpsertUserPrintlogApi", "GetUserFavoriteItemApi", "GetUserRivalDataApi", "GetUserRivalMusicApi",
|
||||
"GetUserScoreRankingApi", "UpsertClientBookkeepingApi", "UpsertClientSettingApi",
|
||||
"UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi", "CMLoginApi", "CMLogoutApi",
|
||||
"CMUpsertBuyCardApi")
|
||||
|
||||
val noopEndpoint = endpointList.popAll("GetUserScoreRankingApi", "UpsertClientBookkeepingApi",
|
||||
"UpsertClientSettingApi", "UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi",
|
||||
"CMLoginApi", "CMLogoutApi", "CMUpsertBuyCardApi", "UserLogoutApi")
|
||||
|
||||
val members = this::class.declaredMemberProperties
|
||||
val handlers: Map<String, BaseHandler> = endpointList.associateWith { api ->
|
||||
val name = api.replace("Api", "").lowercase()
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException
|
|||
import ext.invoke
|
||||
import ext.mapApply
|
||||
import ext.minus
|
||||
import icu.samnyan.aqua.net.games.USERNAME_CHARS
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.general.service.CardService
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.UploadUserPlaylogHandler.Companion.playBacklog
|
||||
|
@ -45,6 +46,10 @@ class UpsertUserAllHandler(
|
|||
id = userData?.id ?: 0
|
||||
card = userData?.card ?: cardService.getCardByExtId(userId).orElseThrow()
|
||||
isNetMember = 1
|
||||
|
||||
// Verify user name
|
||||
if (userName.isBlank() || userName.length > 8 || !userName.all { it in USERNAME_CHARS })
|
||||
400 - "Invalid username"
|
||||
})
|
||||
|
||||
// Check playlog backlog
|
||||
|
@ -55,7 +60,7 @@ class UpsertUserAllHandler(
|
|||
// Set users
|
||||
req.run { listOf(userExtend, userOption, userCharacterList, userMapList, userLoginBonusList, userItemList,
|
||||
userMusicDetailList, userCourseList, userFriendSeasonRankingList, userFavoriteList) }
|
||||
.forEach { it?.forEach { it?.user = u } }
|
||||
.flatten().forEach { it?.user = u }
|
||||
|
||||
req.userExtend?.getOrNull(0)?.let {
|
||||
repos.userExtend.save(it.apply { id = repos.userExtend.findSingleByUser(u)()?.id ?: 0 })
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.chunithm.model.response.CodeResp;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2UserLogoutHandler")
|
||||
public class UserLogoutHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserLogoutHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public UserLogoutHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
String json = mapper.write(new CodeResp(1));
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue