feat(aihr): harden M0-M2 mobile training flows
This commit is contained in:
@@ -94,6 +94,12 @@
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
|
||||
/**
|
||||
* SMS verification codes are scoped to the authenticated tenant boundary.
|
||||
*/
|
||||
public final class SmsCodeUtils {
|
||||
|
||||
public static final String MOBILE_CLIENT_ID = "428a8310cd442757ae699df5d894f051";
|
||||
private static final String VERIFY_LOCK_SUFFIX = ":verify-lock";
|
||||
|
||||
private SmsCodeUtils() {
|
||||
}
|
||||
|
||||
public static String cacheKey(String tenantId, String phonenumber) {
|
||||
String resolvedTenantId = StringUtils.blankToDefault(tenantId, TenantConstants.DEFAULT_TENANT_ID);
|
||||
String resolvedPhone = StringUtils.blankToDefault(phonenumber, "");
|
||||
return GlobalConstants.CAPTCHA_CODE_KEY + "sms:" + resolvedTenantId + ":" + resolvedPhone;
|
||||
}
|
||||
|
||||
public static String verificationLockKey(String tenantId, String phonenumber) {
|
||||
return cacheKey(tenantId, phonenumber) + VERIFY_LOCK_SUFFIX;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
@Tag("dev")
|
||||
class SmsCodeUtilsTest {
|
||||
|
||||
private static final String TEST_MOBILE = "13900000000";
|
||||
|
||||
@Test
|
||||
void scopesSmsCodeKeysByTenantAndPhone() {
|
||||
String defaultTenant = SmsCodeUtils.cacheKey("000000", TEST_MOBILE);
|
||||
String anotherTenant = SmsCodeUtils.cacheKey("tenant-b", TEST_MOBILE);
|
||||
|
||||
assertNotEquals(defaultTenant, anotherTenant);
|
||||
assertEquals(defaultTenant, SmsCodeUtils.cacheKey("", TEST_MOBILE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user