You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.ybw.mathapp.util ;
import com.ybw.mathapp.entity.User ;
import java.util.regex.Pattern ;
public class Register {
// 前端接口-完成注册
public static boolean register ( String email , String password1 ) {
User user = new User ( email , password1 ) ;
LoginFileUtils . saveUser ( user ) ;
System . out . println ( "注册成功!您可以使用邮箱和密码登录了。" ) ;
return true ;
}
/**
* 前端接口-密码格式验证
* @param password1 第一次输入的密码
* @return true表示符合要求, false表示不符合
*/
public static boolean isVaildPassword ( String password1 ) {
// 使用正则表达式验证: 长度6-10, 只包含字母数字, 且包含大小写字母和数字
String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,10}$" ;
if ( ! Pattern . matches ( regex , password1 ) ) {
return false ;
}
return true ;
}
/**
* 前端接口-两次密码匹配
* @param password1 第一次输入的密码
* @param password2 第二次输入的密码
* @return true表示符合要求, false表示不符合
*/
public static boolean isEqualPassword ( String password1 , String password2 ) {
if ( ! password1 . equals ( password2 ) ) {
System . out . println ( "两次输入的密码不一致!" ) ;
return false ;
}
return true ;
}
}