Skip to content

Commit 3402d4d

Browse files
committed
토큰을 또 수정해???
1 parent 3c9249d commit 3402d4d

File tree

9 files changed

+402
-22
lines changed

9 files changed

+402
-22
lines changed

lib/inmat/auth/Inmat_token.dart

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
21
import '../database/token_database.dart';
32
import '../inmat_api/inmat_http.dart';
43
import '../inmat_api/account/get_profile.dart';
54

5+
/// 토큰은 저장소에서 꺼내진다.
6+
/// 로그인을 하면 토큰에 값이 추가된다.
7+
/// 로그아웃, 회원탈퇴를 하면 토큰이 사라진다.
8+
/// 액세스토큰이 만료되면 서버에 리프레시토큰과 액세스토큰을 보내 액세스토큰을 재발급 받는다.
9+
///
10+
class Token {
11+
Map<String, dynamic> _token = {};
12+
13+
void set(Map<String, dynamic> token) => _token = token;
14+
15+
Map<String, dynamic> get() => _token;
616

7-
class InMatToken {
8-
final Map<String, dynamic> _token = {};
17+
void clear() => _token.clear();
918

10-
Map<String, dynamic> get token => _token;
19+
bool get isEmpty => _token.isEmpty;
20+
}
21+
22+
class TokenController {
23+
final Token _token = Token();
24+
25+
Map<String, dynamic> get token => _token.get();
1126

1227
final TokenDataBase _tokenDataBase = TokenDataBase();
1328

@@ -17,7 +32,7 @@ class InMatToken {
1732
}
1833

1934
Future<void> saveToken(Map<String, dynamic> token) async {
20-
_token.addAll(token);
35+
_token.set(token);
2136
_tokenDataBase.save(token);
2237
}
2338

@@ -35,7 +50,7 @@ enum AuthStatus {
3550
reSignIn,
3651
}
3752

38-
class InMatProfile extends InMatToken {
53+
class InMatProfile extends TokenController {
3954
final Map<String, dynamic> _profile = {};
4055

4156
Map<String, dynamic> get profile => _profile;
@@ -92,5 +107,3 @@ class InMatProfile extends InMatToken {
92107
saveUser(profile);
93108
}
94109
}
95-
96-

lib/inmat/auth/user_model.dart

+16
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,19 @@ class User {
3333
return "age: $age, email: $email, gender: $gender, nickName: $nickName, profileImgUrl: $profileImgUrl, token: $token";
3434
}
3535
}
36+
37+
38+
39+
class UUU{
40+
41+
42+
43+
int _age;
44+
String _email;
45+
46+
UUU(this._age, this._email);
47+
48+
String get email => _email;
49+
50+
int get age => _age;
51+
}

lib/inmat/inmat_api/inmat_http.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class InMatHttp {
1010
'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0MTIzIiwiYXV0aCI6IlJPTEVfVVNFUiIsI'
1111
'mV4cCI6MTY3MTkwNjY3N30.7XA_GACOS7qyWWWV-KACZFmzc8l4On_viA9fQRLOWejB_XPjynZjDmebVfiM09TmYigACI7S1JiD-BV5E4Jnfw';
1212

13-
// token=InMatAuth.instance.currentUser!.token;
1413
Uri uri = Uri.parse(url);
1514

1615
final Response response = await http.get(
@@ -34,7 +33,7 @@ class InMatHttp {
3433

3534
Uri uri = Uri.parse(url);
3635

37-
var bodyJson = json.encode(body);
36+
String bodyJson = json.encode(body);
3837
final Response response = await http.post(
3938
uri,
4039
headers: {
@@ -53,6 +52,7 @@ class InMatHttp {
5352
Uri uri = Uri.parse(url);
5453

5554
var bodyJson = json.encode(body);
55+
5656
final Response response = await http.patch(
5757
uri,
5858
headers: {

0 commit comments

Comments
 (0)