Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChatClient/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ChatClient.Models;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Configuration;
Expand All @@ -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();
}
}
7 changes: 3 additions & 4 deletions ChatClient/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponseModel<AccessTokenModel>>(request);

var response = App.client.Execute<ResponseModel<AccessTokenModel>>(request);

if (response.IsSuccessStatusCode && response.Data?.Options != null)
{
Expand Down
4 changes: 2 additions & 2 deletions ChatClient/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid>
<md:Snackbar VerticalAlignment="Top"></md:Snackbar>
<Frame x:Name="PageFrame"></Frame>
<Frame x:Name="PageFrame" NavigationUIVisibility="Hidden"></Frame>
</Grid>
</Window>
16 changes: 16 additions & 0 deletions ChatClient/Models/AccessTokenModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
20 changes: 20 additions & 0 deletions ChatClient/Models/LoginModel.cs
Original file line number Diff line number Diff line change
@@ -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;
}

}
}
Expand Down
16 changes: 16 additions & 0 deletions ChatClient/Models/ResponseModel.cs
Original file line number Diff line number Diff line change
@@ -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<T>
{
public string Code { get; set; }
public string Message { get; set; }

public T? Options { get; set; }
}
}
24 changes: 24 additions & 0 deletions ChatClient/Models/SignupModel.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
8 changes: 4 additions & 4 deletions ChatClient/RegisterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponseModel<JsonObject>>(request);
var response = App.client.Execute<ResponseModel<JsonObject>>(request);

if (response.IsSuccessStatusCode && response.Data?.Options != null)
{
Expand Down