添加注册Email选项...
parent
ec3141e02a
commit
da1f129758
|
@ -17,6 +17,7 @@ namespace KMCCC.Authentication
|
|||
/// </summary>
|
||||
public readonly string Username;
|
||||
public readonly string Password;
|
||||
public readonly string Email;
|
||||
HttpHelper http = new HttpHelper();
|
||||
/// <summary>
|
||||
/// 验证服务器地址
|
||||
|
@ -36,6 +37,15 @@ namespace KMCCC.Authentication
|
|||
Password = password;
|
||||
Address = address.IndexOf("http") > 0 ? address : "http://" + address;
|
||||
Port = port;
|
||||
Email = "mc@mc.com";
|
||||
}
|
||||
public CTZAuthenticator(string username, string password, string email, string address, int port = 25565)
|
||||
{
|
||||
Username = username;
|
||||
Password = password;
|
||||
Address = address.IndexOf("http") > 0 ? address : "http://" + address;
|
||||
Port = port;
|
||||
Email = email;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -67,8 +67,9 @@
|
|||
</Grid>
|
||||
</Grid>
|
||||
<Grid Height="246" VerticalAlignment="Bottom">
|
||||
<Grid Margin="20,20,0,20" HorizontalAlignment="Left" Width="391" >
|
||||
<TabControl Background="White" BorderThickness="0">
|
||||
<Grid Margin="20,20,0,20" HorizontalAlignment="Left" Width="400" >
|
||||
<Border BorderThickness="1" BorderBrush="#FF3299CC"/>
|
||||
<!--<TabControl Background="White" BorderThickness="0">
|
||||
<TabItem Header="动态" Background="White" BorderThickness="0" Margin="0" Height="30" FontSize="15" >
|
||||
<ListBox BorderThickness="0" FontSize="15">
|
||||
<ListBoxItem Content="动态" />
|
||||
|
@ -90,7 +91,7 @@
|
|||
</TabItem>
|
||||
<TabItem Header="公告" Background="White" BorderThickness="0" Margin="0" Height="30" FontSize="15" />
|
||||
<TabItem Header="活动" Background="White" BorderThickness="0" Margin="0" Height="30" FontSize="15" />
|
||||
</TabControl>
|
||||
</TabControl>-->
|
||||
</Grid>
|
||||
<Grid Margin="0,20,20,20" HorizontalAlignment="Right" Width="300" ShowGridLines="True">
|
||||
<Border BorderBrush="#FF3299CC" BorderThickness="1">
|
||||
|
|
|
@ -150,37 +150,7 @@ namespace CTZLauncher
|
|||
|
||||
private void register_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
register.IsEnabled = false;
|
||||
if (username.Text.Length == 0 || password.Text.Length == 0)
|
||||
{
|
||||
MessageBox.Show("请输入账号密码!");
|
||||
return;
|
||||
}
|
||||
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport);
|
||||
try
|
||||
{
|
||||
if (auth.isRegistered())
|
||||
{
|
||||
MessageBox.Show("该用户名已注册 请更换用户名!");
|
||||
return;
|
||||
}
|
||||
if (auth.Register())
|
||||
{
|
||||
MessageBox.Show("注册成功!");
|
||||
auth.Login();
|
||||
ServerWindow.Visibility = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
MessageBox.Show("注册失败!");
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
register.IsEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
@ -252,7 +222,7 @@ namespace CTZLauncher
|
|||
{
|
||||
if (option.Version == null)
|
||||
{
|
||||
MessageBoxResult result = MessageBox.Show("是否下载服务器所需要的客户端版本?", "缺少客户端", MessageBoxButton.OKCancel, MessageBoxImage.Question);
|
||||
MessageBoxResult result = MessageBox.Show("是否下载服务器所需要的客户端版本?", "缺少客户端", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
如果要利用文件和注册表虚拟化实现向后
|
||||
兼容性,则删除 requestedExecutionLevel 节点。
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
<applicationRequestMinimum>
|
||||
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
|
||||
|
|
|
@ -7,14 +7,16 @@
|
|||
mc:Ignorable="d"
|
||||
Title="账号注册" Height="300" Width="300">
|
||||
<Grid>
|
||||
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="25" Margin="128,47,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="25" Margin="128,75,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="25" Margin="128,103,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="username" HorizontalAlignment="Left" Height="25" Margin="128,47,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="password" HorizontalAlignment="Left" Height="25" Margin="128,75,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="pwdcfm" HorizontalAlignment="Left" Height="25" Margin="128,103,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<Label x:Name="label" Content="帐 号" HorizontalAlignment="Left" Margin="39,47,0,0" VerticalAlignment="Top"/>
|
||||
<Label x:Name="label1" Content="密 码" HorizontalAlignment="Left" Margin="39,75,0,0" VerticalAlignment="Top"/>
|
||||
<Label x:Name="label2" Content="确认密码" HorizontalAlignment="Left" Margin="39,103,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="textBox2_Copy" HorizontalAlignment="Left" Height="25" Margin="128,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="email" HorizontalAlignment="Left" Height="25" Margin="128,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<Label x:Name="label2_Copy" Content="邮 箱" HorizontalAlignment="Left" Margin="39,133,0,0" VerticalAlignment="Top"/>
|
||||
<Button Content="取消" HorizontalAlignment="Left" Margin="39,189,0,0" VerticalAlignment="Top" Width="75"/>
|
||||
<Button x:Name="reg" Content="注册" HorizontalAlignment="Left" Margin="173,189,0,0" VerticalAlignment="Top" Width="75" Click="reg_Click"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using KMCCC.Authentication;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -16,11 +17,49 @@ namespace CTZLauncher
|
|||
/// <summary>
|
||||
/// Window1.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Window1 : Window
|
||||
public partial class RegisterWindow : Window
|
||||
{
|
||||
public Window1()
|
||||
string serveraddress;
|
||||
int serverport;
|
||||
public RegisterWindow(string serveraddress, int serverport)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.serveraddress = serveraddress;
|
||||
this.serverport = serverport;
|
||||
}
|
||||
|
||||
private void reg_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
reg.IsEnabled = false;
|
||||
if (username.Text.Length == 0 || password.Text.Length == 0)
|
||||
{
|
||||
MessageBox.Show("请输入账号密码!");
|
||||
return;
|
||||
}
|
||||
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport);
|
||||
try
|
||||
{
|
||||
if (auth.isRegistered())
|
||||
{
|
||||
MessageBox.Show("该用户名已注册 请更换用户名!");
|
||||
return;
|
||||
}
|
||||
if (auth.Register())
|
||||
{
|
||||
MessageBox.Show("注册成功!");
|
||||
Close();
|
||||
}
|
||||
else
|
||||
MessageBox.Show("注册失败!");
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reg.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue