Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] #164 - bearer token constant ํ™” #165

Merged
merged 3 commits into from
Dec 17, 2021
Merged
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
4 changes: 4 additions & 0 deletions NADA-iOS-forRelease.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
77DFB871274F92F9000CD36F /* AddWithIdBottomSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77DFB870274F92F9000CD36F /* AddWithIdBottomSheetViewController.swift */; };
77F2C0EB27632A91007641E3 /* CardHarmonyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F2C0EA27632A91007641E3 /* CardHarmonyViewController.swift */; };
77F2C0ED27632AA7007641E3 /* CardHarmony.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77F2C0EC27632AA7007641E3 /* CardHarmony.storyboard */; };
77F47D93276C79B600414659 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F47D92276C79B600414659 /* Header.swift */; };
DBBB91E1639641F40C5B4416 /* Pods_NADA_iOS_forRelease.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A2183AE0E469153221624A0 /* Pods_NADA_iOS_forRelease.framework */; };
F811720027383097002742CF /* ChangeGroupRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F81171FF27383097002742CF /* ChangeGroupRequest.swift */; };
F822E7A92709CEB60020452C /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F822E7A82709CEB60020452C /* Notification.swift */; };
Expand Down Expand Up @@ -215,6 +216,7 @@
77DFB870274F92F9000CD36F /* AddWithIdBottomSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWithIdBottomSheetViewController.swift; sourceTree = "<group>"; };
77F2C0EA27632A91007641E3 /* CardHarmonyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardHarmonyViewController.swift; sourceTree = "<group>"; };
77F2C0EC27632AA7007641E3 /* CardHarmony.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CardHarmony.storyboard; sourceTree = "<group>"; };
77F47D92276C79B600414659 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = "<group>"; };
7F4EE1D042EC783FA8528743 /* Pods-NADA-iOS-forRelease.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NADA-iOS-forRelease.debug.xcconfig"; path = "Target Support Files/Pods-NADA-iOS-forRelease/Pods-NADA-iOS-forRelease.debug.xcconfig"; sourceTree = "<group>"; };
F81171FF27383097002742CF /* ChangeGroupRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeGroupRequest.swift; sourceTree = "<group>"; };
F822E7A82709CEB60020452C /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -908,6 +910,7 @@
F822E7A82709CEB60020452C /* Notification.swift */,
F8C83FC2272FA17B0009DF0D /* URL.swift */,
3927A7D6275F2A9B008BCD2A /* UserDefaults.swift */,
77F47D92276C79B600414659 /* Header.swift */,
);
path = Constants;
sourceTree = "<group>";
Expand Down Expand Up @@ -1112,6 +1115,7 @@
39523E09270184A700536900 /* CardListViewController.swift in Sources */,
F85711A5274A6B2200F59F0B /* CardCreationPreviewViewController.swift in Sources */,
777FF89B27359B7800BF69D3 /* Groups.swift in Sources */,
77F47D93276C79B600414659 /* Header.swift in Sources */,
397B75102763A5F5004AEB03 /* OpenSourceViewController.swift in Sources */,
777FF89F27364B7B00BF69D3 /* GroupEditRequest.swift in Sources */,
399C55DF2711949D00845A54 /* CGPoint+Distance.swift in Sources */,
Expand Down
18 changes: 18 additions & 0 deletions NADA-iOS-forRelease/Resouces/Constants/Header.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Header.swift
// NADA-iOS-forRelease
//
// Created by Yi Joon Choi on 2021/12/17.
//

import Foundation

extension Const {
struct Header {
// static let bearerHeader = ["Content-Type": "application/json",
// "Authorization": "Bearer " + Const.UserDefaults.accessToken]
static let bearerHeader = ["Authorization": "Bearer " + "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYWRhMiIsImF1dGgiOiJST0xFX1VTRVIiLCJleHAiOjE2NDAxMTAyNTB9.qH2fMkrtcVk9GtMEsBEWo0YFvIRTgKPVntBzpeGyyAe5POqnuKf3AtUTJE8yy6gPsAOl0bq8ChCn4RCL0fchpA"]
static let basicHeader = ["Content-Type": "application/json",
"Authorization": "Bearer " + "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYWRhMiIsImF1dGgiOiJST0xFX1VTRVIiLCJleHAiOjE2NDAxMTAyNTB9.qH2fMkrtcVk9GtMEsBEWo0YFvIRTgKPVntBzpeGyyAe5POqnuKf3AtUTJE8yy6gPsAOl0bq8ChCn4RCL0fchpA"]
}
}
Comment on lines +14 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ‘๐Ÿช“

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ extension GroupService: TargetType {
return URL(string: Const.URL.baseURL)!
}

var authorizationType: AuthorizationType? {
switch self {
case .groupListFetch, .cardListFetchInGroup, .groupDelete, .cardDeleteInGroup:
return .bearer
case .groupAdd, .groupEdit, .cardAddInGroup, .changeCardGroup, .groupReset:
return .bearer
}
}

var path: String {
switch self {
case .groupListFetch, .groupReset:
Expand Down Expand Up @@ -84,9 +93,9 @@ extension GroupService: TargetType {
var headers: [String: String]? {
switch self {
case .groupListFetch, .cardListFetchInGroup, .groupDelete, .cardDeleteInGroup:
return .none
return Const.Header.bearerHeader
case .groupAdd, .groupEdit, .cardAddInGroup, .changeCardGroup:
return ["Content-Type": "application/json"]
return Const.Header.bearerHeader
case .groupReset(let token):
return ["Content-Type": "application/json", "Authorization": "Bearer " + token]
}
Expand Down