diff --git a/ChatClient/App.xaml.cs b/ChatClient/App.xaml.cs index 2def0a7..2696a4f 100644 --- a/ChatClient/App.xaml.cs +++ b/ChatClient/App.xaml.cs @@ -1,4 +1,5 @@ using ChatClient.Models; +using RestSharp; using System; using System.Collections.Generic; using System.Configuration; @@ -17,5 +18,7 @@ public partial class App : Application { public static Frame PageFrame { get; set; } public static AccessTokenModel? AccessToken { get; set; } + + public static RestClient client = new RestClient(); } } diff --git a/ChatClient/LoginPage.xaml.cs b/ChatClient/LoginPage.xaml.cs index c3757e0..28b36a3 100644 --- a/ChatClient/LoginPage.xaml.cs +++ b/ChatClient/LoginPage.xaml.cs @@ -38,11 +38,10 @@ private void LoginBtnClick(object sender, RoutedEventArgs e) string password = PasswordTextBox.Password; LoginModel model = new LoginModel(id, password); - RestClient client = new RestClient(); - RestRequest request = new RestRequest("http://localhost:3000/signIn", Method.Post); + RestRequest request = new RestRequest("http://localhost:3000/user/signIn", Method.Post); request.AddBody(model); - - var response = client.Execute>(request); + + var response = App.client.Execute>(request); if (response.IsSuccessStatusCode && response.Data?.Options != null) { diff --git a/ChatClient/MainWindow.xaml b/ChatClient/MainWindow.xaml index 7bdab70..da828ff 100644 --- a/ChatClient/MainWindow.xaml +++ b/ChatClient/MainWindow.xaml @@ -13,9 +13,9 @@ TextOptions.TextRenderingMode="Auto" Background="{DynamicResource MaterialDesignPaper}" FontFamily="{DynamicResource MaterialDesignFont}" - Title="MainWindow" Height="450" Width="800" MinWidth="300" MinHeight="500"> + Title="MainWindow" Height="450" Width="800" MinWidth="300" MinHeight="500" WindowStyle="None"> - + diff --git a/ChatClient/Models/AccessTokenModel.cs b/ChatClient/Models/AccessTokenModel.cs new file mode 100644 index 0000000..bda226a --- /dev/null +++ b/ChatClient/Models/AccessTokenModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace ChatClient.Models +{ + public class AccessTokenModel + { + [JsonPropertyName("token")] + public string Token { get; set; } + public string RefreshToken { get; set; } + } +} \ No newline at end of file diff --git a/ChatClient/Models/LoginModel.cs b/ChatClient/Models/LoginModel.cs new file mode 100644 index 0000000..0a3965f --- /dev/null +++ b/ChatClient/Models/LoginModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ChatClient.Models +{ + internal class LoginModel + { + public string Id { get; set; } + public string Password { get; set; } + + public LoginModel(string id, string password) { + Id = id; + Password = password; + } + + } +} diff --git a/ChatClient/Models/ResponseModel.cs b/ChatClient/Models/ResponseModel.cs new file mode 100644 index 0000000..19852b9 --- /dev/null +++ b/ChatClient/Models/ResponseModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ChatClient.Models +{ + internal class ResponseModel + { + public string Code { get; set; } + public string Message { get; set; } + + public T? Options { get; set; } + } +} diff --git a/ChatClient/Models/SignupModel.cs b/ChatClient/Models/SignupModel.cs new file mode 100644 index 0000000..ec08b19 --- /dev/null +++ b/ChatClient/Models/SignupModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ChatClient.Models +{ + internal class SignupModel + { + public string Id { get; set; } + + public string Name { get; set; } + + public string Password { get; set; } + + public SignupModel(string id, string password, string name) + { + Id = id; + Name = name; + Password = password; + } + } +} diff --git a/ChatClient/RegisterPage.xaml.cs b/ChatClient/RegisterPage.xaml.cs index 7e30bd2..cb00335 100644 --- a/ChatClient/RegisterPage.xaml.cs +++ b/ChatClient/RegisterPage.xaml.cs @@ -41,17 +41,17 @@ private void RegisterBtnClick(object sender, RoutedEventArgs e) string password = PasswordTextBox.Password; string passwordConfirm = PasswordConfirmTextBox.Password; + if (password != passwordConfirm) { MessageBox.Show("비밀번호랑 비밀번호 확인이 달라요!"); } - + // TODO: 서버에 회원가입 요청 보내기 SignupModel model = new SignupModel(id, password, username); - RestClient client = new RestClient(); - RestRequest request = new RestRequest("http://localhost:3000/signUp", Method.Post); + RestRequest request = new RestRequest("http://localhost:3000/user/signUp", Method.Post); request.AddBody(model); - var response = client.Execute>(request); + var response = App.client.Execute>(request); if (response.IsSuccessStatusCode && response.Data?.Options != null) {