From f588bb24239354cc721089b4de873f5a97791665 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 16 Apr 2024 12:27:54 +0100 Subject: [PATCH 1/5] Testing branch creation and pushing via Xcode. Only changed Acebook to Pawbook. --- .DS_Store | Bin 6148 -> 6148 bytes MobileAcebook/WelcomePageView.swift | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 7fa1be84d357e72af5ed943ecd6fe9ee00e303cc..ef9d0d31efdf5d6caf352af0c06d104a5119f297 100644 GIT binary patch delta 134 zcmZoMXfc@JFUrQiz`)4BAi%(o!;s40$dC*qlQuK5EN5h7o7~1^$f!4Y2a_+5WMg&) zl3vX2KynhZrscf83}%aG!klb@WFlb-}s4K#(p4v6*sg8`7mz`(=c&EN^t;SDs$4G3}RTMtz0f~1dk zvH+7VqswGFCSM@g!{iJkFEF_SNeO06`z=T+c^HBiTp1i0To`rn$Lkd=xfoy>4 O1A35`Wiva+Uw#1d_(H(| diff --git a/MobileAcebook/WelcomePageView.swift b/MobileAcebook/WelcomePageView.swift index 96006af9..8d605011 100644 --- a/MobileAcebook/WelcomePageView.swift +++ b/MobileAcebook/WelcomePageView.swift @@ -13,7 +13,7 @@ struct WelcomePageView: View { VStack { Spacer() - Text("Welcome to Acebook!") + Text("Welcome to Pawbook!") .font(.largeTitle) .padding(.bottom, 20) .accessibilityIdentifier("welcomeText") From d5f2c312900381924419f4df4fcb63b14cccdbb4 Mon Sep 17 00:00:00 2001 From: Maria Basia Date: Tue, 16 Apr 2024 12:35:01 +0100 Subject: [PATCH 2/5] First commit - signup function added to AuthenticationService.swift. User model was updated as well --- .DS_Store | Bin 6148 -> 6148 bytes MobileAcebook/Models/User.swift | 8 +++-- .../Services/AuthenticationService.swift | 32 ++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.DS_Store b/.DS_Store index 7fa1be84d357e72af5ed943ecd6fe9ee00e303cc..aa44966853af418bd5abc15663ce08842a8d08f5 100644 GIT binary patch delta 53 zcmZoMXfc@JFUrcmz`)4BAi%(o!;s40$dC*qlQuK5EN5h7-Q33H$hi4GGY8AWhE1E< IIsWnk03q!R83}%aG!klb@WFlb-}s4K#(p4v6*sg8`7mz`(=c&EN^t;SDs$4G3}RTMtz0f~1dk qvjCGVqb3hS5Q8g&BZCWrFOb$_NM%UDYVG>XcFf`|o7p-3@&f?fUoQLr diff --git a/MobileAcebook/Models/User.swift b/MobileAcebook/Models/User.swift index ea748dd0..1daa5af5 100644 --- a/MobileAcebook/Models/User.swift +++ b/MobileAcebook/Models/User.swift @@ -5,7 +5,11 @@ // Created by Josué Estévez Fernández on 01/10/2023. // -public struct User { - let username: String + + +public struct User: Encodable { + let imgUrl: String + let email: String let password: String + let username: String } diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift index 9f7181c3..3d97eaa6 100644 --- a/MobileAcebook/Services/AuthenticationService.swift +++ b/MobileAcebook/Services/AuthenticationService.swift @@ -4,10 +4,38 @@ // // Created by Josué Estévez Fernández on 01/10/2023. // +import Foundation + + class AuthenticationService: AuthenticationServiceProtocol { + struct Response: Codable { + let message : String + } + func signUp(user: User) -> Bool { - // Logic to call the backend API for signing up - return true // placeholder + guard let url = URL(string: "http://localhost:3000/users") else {return false} + + var urlRequest = URLRequest(url: url) + urlRequest.httpMethod = "POST" + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + + let body = user + urlRequest.httpBody = try? JSONEncoder().encode(user) //JSONSerialization.data(withJSONObject: body, options: .fragmentsAllowed) + let task = URLSession.shared.dataTask(with : urlRequest) {data, response, error in + guard let data = data else {return} + do { + let response = try JSONSerialization.jsonObject(with: data, options: .allowFragments) + print(response) + print("User created successfully") + } + catch { + print(error) + } + } + task.resume() + return true } + } + From 32e21a907e8f699e5ae785cf21e9eb52806130db Mon Sep 17 00:00:00 2001 From: Maria Basia Date: Tue, 16 Apr 2024 14:34:01 +0100 Subject: [PATCH 3/5] .DS_Store file added to .gitignore file --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + .../Services/AuthenticationService.swift | 4 ++++ 3 files changed, 5 insertions(+) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index aa44966853af418bd5abc15663ce08842a8d08f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!Ab)$5Pex&sEANR(2I~S5d4F+tcM;vsds5BqAsjh1&@38cli5 zw~KQ$+_5_>?_WdT!?&o}VC!~wf5&VV!E4E!+$ShGb2 zJBDtZ0cXG&STG>phe#DH6Sju>>7dao0I^563fpp*keHaTOxPOo2_;x4(LzJIVgw7P zKc;bI!q(8j5p-teNi&CZLkT)N{ZWS_l!k7d0cT*9fi3F}rT(9-zyGfWdCwVe2L2TT zp;uj0BQ7b`*3ROj)<)_zRYb Date: Tue, 16 Apr 2024 14:45:44 +0100 Subject: [PATCH 4/5] deleted .DS_Store file and removed not needed comments --- MobileAcebook/Services/AuthenticationService.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift index f8ad4f16..02b635e9 100644 --- a/MobileAcebook/Services/AuthenticationService.swift +++ b/MobileAcebook/Services/AuthenticationService.swift @@ -21,7 +21,7 @@ class AuthenticationService: AuthenticationServiceProtocol { urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") let body = user - urlRequest.httpBody = try? JSONEncoder().encode(user) //JSONSerialization.data(withJSONObject: body, options: .fragmentsAllowed) + urlRequest.httpBody = try? JSONEncoder().encode(user) let task = URLSession.shared.dataTask(with : urlRequest) {data, response, error in guard let data = data else {return} do { From 787e45266672e738cd19813b51875c0a3b2daff4 Mon Sep 17 00:00:00 2001 From: George Paul Date: Tue, 16 Apr 2024 15:11:13 +0100 Subject: [PATCH 5/5] removed DS_Store added DS_Store to gitignore to avoid future pushes --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + .../xcshareddata/WorkspaceSettings.xcsettings | 5 +++++ 3 files changed, 6 insertions(+) delete mode 100644 .DS_Store create mode 100644 MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ef9d0d31efdf5d6caf352af0c06d104a5119f297..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO-sW-5Pch~w1`kd(2I~?Q1Bnbk{o*Q;>W$T5m6%%tKczr|AYV2lfIcg!iBcRwr2<)SEMHMvFHF>&&#rjt4Bufzne+zBOe?uJJ^v31vCduy@n zZ(zG5%L>m}wKzUn90waXt}sInPju7b+2%Wo9z}aZ?r-3|rojm3$e2wza>iLdAaA~- zR@7A^fte{_3YY@FssPVyvEi;qi>81nU<#}iknclG7fb?H9`)0~pjQCmfN3?hsS8&O=gXOoL%$?o<B!^>BfD@zaXLElv37?`JX$mbOo65X zTmI)*&i}0c{@*OJU#5U5@UIkbgY+Vua!TQB?MzP2+L%74i%GxA^8fiDExY3Bd{ diff --git a/.gitignore b/.gitignore index 166face2..4b1e6d9e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.xcworkspace/xcuserdata/ DerivedData/ build/ +.DS_Store \ No newline at end of file diff --git a/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,5 @@ + + + + +