Skip to content

Commit

Permalink
Merge pull request #15 from Google-Developer-Student-Clubs-TUK/feat/s…
Browse files Browse the repository at this point in the history
…ignUp

Feat/sign up
  • Loading branch information
Chynmn authored Dec 26, 2022
2 parents f4f8e42 + 942f377 commit e1bc10c
Show file tree
Hide file tree
Showing 102 changed files with 19,819 additions and 24 deletions.
176 changes: 173 additions & 3 deletions GOiOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions GOiOS.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions GOiOS.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion GOiOS/GOiOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
struct GOiOSApp: App {
var body: some Scene {
WindowGroup {
ScheduleUIView()
SignInView()
}
}
}
21 changes: 21 additions & 0 deletions GOiOS/SignIn.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// SignIn.swift
// GOiOS
//
// Created by /Chynmn/M1 pro—̳͟͞͞♡ on 2022/12/25.
//

import Foundation

func setItemKeyChain(userId: String, rft: String){
let previousQuery: [CFString: Any] = [kSecClass: kSecClassIdentity, kSecAttrAccount: userId]

let updateQuery: [CFString: Any] = [kSecValueData: rft]
let status = SecItemUpdate(previousQuery as CFDictionary, updateQuery as CFDictionary)

if status == errSecSuccess {
print("Update!")
} else {
print("Update fail")
}
}
35 changes: 35 additions & 0 deletions GOiOS/SignUp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// SignUp.swift
// GOiOS
//
// Created by /Chynmn/M1 pro—̳͟͞͞♡ on 2022/12/22.
//

import Foundation


func sendPostRequest(_ url: String, parameters: [String: String], completion: @escaping ([String: Any]?, Error?) -> Void) {
let targetUrl = URL(string: url)
let paramData = try? JSONSerialization.data(withJSONObject: parameters)

var request = URLRequest(url: targetUrl!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = paramData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard
let data = data, // is there data
let response = response as? HTTPURLResponse, // is there HTTP response
200 ..< 300 ~= response.statusCode, // is statusCode 2XX
error == nil // was there no error
else {
completion(nil, error)
return
}

let responseObject = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
completion(responseObject, nil)
}
task.resume()
}
File renamed without changes.
33 changes: 28 additions & 5 deletions GOiOS/SignInView.swift → GOiOS/View/SignInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
import UIKit
import SwiftUI
import Alamofire

struct SignInView: View {
@State private var id : String = ""
Expand All @@ -15,6 +16,8 @@ struct SignInView: View {
// @State private var showingAlert: Bool = false
// @State private var correctId: String = ""
// @State private var correctPw: String = ""
@State private var loginStatus: Bool = false // TODO env 변수로 선언 후 토큰 계속 확인
@State private var userAccessToken: String = ""


var body: some View {
Expand Down Expand Up @@ -60,7 +63,27 @@ struct SignInView: View {
}

Button (action: {

// print(self.id + self.pw)
//
// let rft = readItemKeyChain(userId: self.id)
// if rft != nil {
// UserDefaults.standard.set(rft, forKey: self.id)
// }else{
// sendPostRequest("<http://localhost:8080/api/v1/user>", parameters: ["username": self.id, "password": self.pw]){
// responseObject, error in guard let _ = responseObject, error == nil else {
// print(error ?? "Unknown error")
// return
// }
// self.loginStatus = true
//
// if let rftToken = responseObject{
// let rft = rftToken["refresh"] as? String
// self.userAccessToken = rftToken["access"] as? String ?? ""
// setItemKeyChain(userId: self.email, rft: rft!)
// UserDefaults.standard.set(rft, forKey: self.email)
// }
// }
// }
}) {
HStack {
Text("Sign in")
Expand All @@ -77,16 +100,16 @@ struct SignInView: View {
}

// NavigationLink(destination: SignUpView()) {
Button (action: {
}) {
// Button (action: {
//
// }) {
NavigationLink(destination: SignUpView()) {
Text("Sign Up")
.font(.caption)
.underline()
.foregroundColor(.black)
.navigationTitle("")
}
// }
}
.frame(width: 300, height: 50)
}
Expand Down
39 changes: 24 additions & 15 deletions GOiOS/SignUpView.swift → GOiOS/View/SignUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
import UIKit
import SwiftUI
import Alamofire

struct SignUpView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
Expand All @@ -17,19 +18,19 @@ struct SignUpView: View {
@State private var sign_pw : String = ""
@State private var sign_pw_check : String = ""

var btnBack : some View { Button(action: {
self.showingAlert = true
}){
Text("뒤로가기")
}.alert(isPresented: $showingAlert){
Alert(title: Text("회원 가입 취소"), message: Text("회원가입을 취소하시겠습니까?"),
primaryButton: .destructive(Text("취소하기"), action: {
presentationMode.wrappedValue.dismiss()
})
, secondaryButton: .cancel(Text("이어하기")))
}
}
// var btnBack : some View { Button(action: {
// self.showingAlert = true
// }){
// Text("뒤로가기")
// }.alert(isPresented: $showingAlert){
// Alert(title: Text("회원 가입 취소"), message: Text("회원가입을 취소하시겠습니까?"),
// primaryButton: .destructive(Text("취소하기"), action: {
// presentationMode.wrappedValue.dismiss()
// })
// , secondaryButton: .cancel(Text("이어하기")))
// }
//
// }

var body: some View {
VStack {
Expand All @@ -46,7 +47,7 @@ struct SignUpView: View {
Image(systemName: "person")
.foregroundColor(.secondary)

TextField("Please enter your ID", text: $sign_id)
TextField("Please enter your ID", text: $sign_id).keyboardType(.default).autocapitalization(.none)
.disableAutocorrection(true)
}
.padding()
Expand All @@ -57,7 +58,7 @@ struct SignUpView: View {
HStack {
Image(systemName: "lock")
.foregroundColor(.secondary)
SecureField("Please enter your PW", text: $sign_pw)
SecureField("Please enter your PW", text: $sign_pw).keyboardType(.default)
}
.padding()
.background(Capsule().fill(.tertiary))
Expand All @@ -68,7 +69,15 @@ struct SignUpView: View {
}

Button (action: {
print(self.sign_id + self.sign_pw)

sendPostRequest("http://localhost:8000/auth/signup", parameters: ["ID": self.sign_id, "PW": self.sign_pw]){
responseObject, error in guard let _ = responseObject, error == nil else {
print(error ?? "Unkown error")
return
}
}
self.presentationMode.wrappedValue.dismiss()
}) {
Text("Sign Up")
.padding()
Expand Down
21 changes: 21 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'GOiOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for GOiOS
pod 'SwiftyJSON'
pod 'Alamofire', '~> 5.5'

target 'GOiOSTests' do
inherit! :search_paths
# Pods for testing
end

target 'GOiOSUITests' do
# Pods for testing
end

end
20 changes: 20 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PODS:
- Alamofire (5.6.4)
- SwiftyJSON (5.0.1)

DEPENDENCIES:
- Alamofire (~> 5.5)
- SwiftyJSON

SPEC REPOS:
trunk:
- Alamofire
- SwiftyJSON

SPEC CHECKSUMS:
Alamofire: 4e95d97098eacb88856099c4fc79b526a299e48c
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e

PODFILE CHECKSUM: 70184d948cb582dabc5b70574c54776ca1894f3c

COCOAPODS: 1.11.3
19 changes: 19 additions & 0 deletions Pods/Alamofire/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e1bc10c

Please sign in to comment.