2024-08-16 05:15:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2024-08-16 10:09:19 +00:00
|
|
|
|
using System.Security.Principal;
|
2024-08-16 05:15:18 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using RustTools.muqing;
|
2024-08-16 10:09:19 +00:00
|
|
|
|
using RustTools.Views;
|
2024-08-17 06:41:34 +00:00
|
|
|
|
using static IniHelper;
|
2024-08-16 05:15:18 +00:00
|
|
|
|
|
|
|
|
|
namespace RustTools.ApiFox;
|
|
|
|
|
|
2024-08-16 10:09:19 +00:00
|
|
|
|
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
|
|
|
|
#pragma warning disable IDE1006 // 命名样式
|
2024-08-16 05:15:18 +00:00
|
|
|
|
public class user
|
|
|
|
|
{
|
2024-08-16 10:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 登陆
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="account"></param>
|
|
|
|
|
/// <param name="passWord"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-08-16 05:15:18 +00:00
|
|
|
|
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[][]
|
|
|
|
|
{
|
2024-08-16 10:09:19 +00:00
|
|
|
|
new[]{ "account",account},
|
|
|
|
|
new[]{ "passWord", passWord },
|
|
|
|
|
new[]{ "isEmail", v.ToString().ToLower() }
|
2024-08-16 05:15:18 +00:00
|
|
|
|
});
|
|
|
|
|
return task;
|
|
|
|
|
}
|
2024-08-16 10:09:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="account"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-08-16 05:15:18 +00:00
|
|
|
|
public static async Task<string> SpaceInfo(string account)
|
|
|
|
|
{
|
|
|
|
|
var task = await wl.postAsync("/php/user.php?action=getSpaceInfo", new string[][]
|
|
|
|
|
{
|
2024-08-16 10:09:19 +00:00
|
|
|
|
new[]{ "account",account}
|
2024-08-16 05:15:18 +00:00
|
|
|
|
});
|
|
|
|
|
return task;
|
|
|
|
|
}
|
2024-08-16 10:09:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-17 06:41:34 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 激活用户
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="account"></param>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-08-16 10:09:19 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-17 06:41:34 +00:00
|
|
|
|
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-16 05:15:18 +00:00
|
|
|
|
}
|