130 lines
4.0 KiB
C#
130 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Principal;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using RustTools.muqing;
|
|
using RustTools.Views;
|
|
using static IniHelper;
|
|
|
|
namespace RustTools.ApiFox;
|
|
|
|
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
|
#pragma warning disable IDE1006 // 命名样式
|
|
public class user
|
|
{
|
|
/// <summary>
|
|
/// 登陆
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <param name="passWord"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> loginPc(string account, string passWord)
|
|
{
|
|
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
|
var v = Regex.IsMatch(account, pattern);
|
|
//gj.sc(account + " " + v); //这里不知道为什么会出现 True 而不是 true 导致识别邮箱失败
|
|
var task = await wl.postAsync("/php/user.php?action=loginPc", new string[][]
|
|
{
|
|
new[]{ "account",account},
|
|
new[]{ "passWord", passWord },
|
|
new[]{ "isEmail", v.ToString().ToLower() }
|
|
});
|
|
return task;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> SpaceInfo(string account)
|
|
{
|
|
var task = await wl.postAsync("/php/user.php?action=getSpaceInfo", new string[][]
|
|
{
|
|
new[]{ "account",account}
|
|
});
|
|
return task;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 注册
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <param name="email"></param>
|
|
/// <param name="passWord"></param>
|
|
/// <param name="userName"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> register(string account,string userName,string passWord,string email)
|
|
{
|
|
var task = await wl.postAsync("/php/user.php?action=register", new string[][]
|
|
{
|
|
new []{ "account",account},
|
|
new []{ "userName", userName },
|
|
new []{ "passWord", passWord },
|
|
new []{ "email", email },
|
|
new []{ "appID",gj.GetUUID()}
|
|
});
|
|
return task;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 激活用户
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> enableAccount(string account, string key)
|
|
{
|
|
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
|
|
{
|
|
new []{ "account",account},
|
|
new []{ "key", key }
|
|
});
|
|
return task;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改密码 发送邮箱验证码
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> requestChangePassword(string account)
|
|
{
|
|
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
|
var v = Regex.IsMatch(account, pattern);
|
|
var task = await wl.postAsync("/php/user.php?action=requestChangePassword", new string[][]
|
|
{
|
|
new []{ "account",account},
|
|
new []{ "isEmail", v.ToString().ToLower()}
|
|
});
|
|
return task;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改密码
|
|
/// </summary>
|
|
/// <param name="account"></param>
|
|
/// <param name="newPassword"></param>
|
|
/// <param name="code"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> changePassword(string account, string newPassword, string code)
|
|
{
|
|
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
|
var v = Regex.IsMatch(account, pattern);
|
|
var task = await wl.postAsync("/php/user.php?action=changePassword", new string[][]
|
|
{
|
|
new []{ "account",account},
|
|
new []{ "isEmail", v.ToString().ToLower()},
|
|
new []{ "code", code},
|
|
new []{ "newPassword", newPassword}
|
|
});
|
|
return task;
|
|
}
|
|
|
|
}
|