From bf293fadb70aae30dc1984f23537f0442675ca0c Mon Sep 17 00:00:00 2001
From: Ami Day <amiday@Amis-MacBook-Pro-2.local>
Date: Tue, 10 Oct 2023 10:15:12 +0100
Subject: [PATCH 01/10] started login

---
 MobileAcebook.xcodeproj/project.pbxproj |  4 ++
 MobileAcebook/LogInView.swift           | 61 +++++++++++++++++++++++++
 MobileAcebook/Models/User.swift         |  4 +-
 MobileAcebook/WelcomePageView.swift     | 54 +++++++++++++---------
 4 files changed, 100 insertions(+), 23 deletions(-)
 create mode 100644 MobileAcebook/LogInView.swift

diff --git a/MobileAcebook.xcodeproj/project.pbxproj b/MobileAcebook.xcodeproj/project.pbxproj
index 5506db3b..e7c60367 100644
--- a/MobileAcebook.xcodeproj/project.pbxproj
+++ b/MobileAcebook.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		10D70DA82AD44C30003B552B /* LogInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D70DA72AD44C30003B552B /* LogInView.swift */; };
 		AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */; };
 		AE5D85B42AC8A224009680C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B32AC8A224009680C6 /* Assets.xcassets */; };
 		AE5D85B72AC8A224009680C6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B62AC8A224009680C6 /* Preview Assets.xcassets */; };
@@ -39,6 +40,7 @@
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
+		10D70DA72AD44C30003B552B /* LogInView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInView.swift; sourceTree = "<group>"; };
 		AE5D85AC2AC8A221009680C6 /* MobileAcebook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileAcebook.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileAcebookApp.swift; sourceTree = "<group>"; };
 		AE5D85B32AC8A224009680C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -111,6 +113,7 @@
 				AE5D85B32AC8A224009680C6 /* Assets.xcassets */,
 				AE5D85B52AC8A224009680C6 /* Preview Content */,
 				AE5D85D92AC8A337009680C6 /* WelcomePageView.swift */,
+				10D70DA72AD44C30003B552B /* LogInView.swift */,
 			);
 			path = MobileAcebook;
 			sourceTree = "<group>";
@@ -304,6 +307,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				10D70DA82AD44C30003B552B /* LogInView.swift in Sources */,
 				AE5D85E12AC9AFA9009680C6 /* AuthenticationService.swift in Sources */,
 				AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */,
 				AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */,
diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
new file mode 100644
index 00000000..ffc120ba
--- /dev/null
+++ b/MobileAcebook/LogInView.swift
@@ -0,0 +1,61 @@
+//
+//  LogInView.swift
+//  MobileAcebook
+//
+//  Created by Ami Day on 09/10/2023.
+//
+
+import Foundation
+import SwiftUI
+import Combine
+
+struct LogInView: View {
+    @State private var userModel = User(email: "", password: "")
+    
+    private func onEmailInputChanged(changedEmail: String) {
+            print("-----> in onEmailInputChanged: \(changedEmail) ")
+        }
+    
+    var body: some View {
+        
+        ZStack {
+            VStack {
+                
+                Spacer()
+                
+                Image("makers-logo")
+                    .resizable()
+                    .scaledToFit()
+                    .frame(width: 200, height: 200)
+                    .accessibilityIdentifier("makers-logo")
+                
+                Spacer()
+                
+                TextField("Email", text: $userModel.email)
+                     .onChange(of: userModel.email, perform: onEmailInputChanged)
+                
+                NavigationLink(destination: LogInView()) {
+                    Text("Login")
+                        .padding()
+                        .background(Color.blue)
+                        .foregroundColor(Color.white)
+                        .cornerRadius(10)
+                }
+                
+                Button("Sign Up") {
+                    // TODO: sign up logic
+                }
+                .accessibilityIdentifier("signUpButton")
+                
+            }
+            
+            Spacer()
+        }
+            }
+        }
+
+struct LogInView_Previews: PreviewProvider {
+                    static var previews: some View {
+                        LogInView()
+                    }
+                }
diff --git a/MobileAcebook/Models/User.swift b/MobileAcebook/Models/User.swift
index ea748dd0..04d3a36c 100644
--- a/MobileAcebook/Models/User.swift
+++ b/MobileAcebook/Models/User.swift
@@ -6,6 +6,6 @@
 //
 
 public struct User {
-    let username: String
-    let password: String
+    var email: String
+    var password: String
 }
diff --git a/MobileAcebook/WelcomePageView.swift b/MobileAcebook/WelcomePageView.swift
index 96006af9..46e32005 100644
--- a/MobileAcebook/WelcomePageView.swift
+++ b/MobileAcebook/WelcomePageView.swift
@@ -10,28 +10,40 @@ import SwiftUI
 struct WelcomePageView: View {
     var body: some View {
         ZStack {
-            VStack {
-                Spacer()
-
-                Text("Welcome to Acebook!")
-                    .font(.largeTitle)
-                    .padding(.bottom, 20)
-                    .accessibilityIdentifier("welcomeText")
-
-                Spacer()
-
-                Image("makers-logo")
-                    .resizable()
-                    .scaledToFit()
-                    .frame(width: 200, height: 200)
-                    .accessibilityIdentifier("makers-logo")
-                
-                Spacer()
-
-                Button("Sign Up") {
-                    // TODO: sign up logic
+            
+            NavigationView {
+                VStack {
+                    
+                    Spacer()
+                    
+                    Text("Welcome to Acebook!")
+                        .font(.largeTitle)
+                        .padding(.bottom, 20)
+                        .accessibilityIdentifier("welcomeText")
+                    
+                    Spacer()
+                    
+                    Image("makers-logo")
+                        .resizable()
+                        .scaledToFit()
+                        .frame(width: 200, height: 200)
+                        .accessibilityIdentifier("makers-logo")
+                    
+                    Spacer()
+                    
+                    Button("Sign Up") {
+                        // TODO: sign up logic
+                    }
+                    .accessibilityIdentifier("signUpButton")
+                    
+                    NavigationLink(destination: LogInView()) {
+                        Text("Login")
+                            .padding()
+                            .background(Color.blue)
+                            .foregroundColor(Color.white)
+                            .cornerRadius(10)
+                    }
                 }
-                .accessibilityIdentifier("signUpButton")
                 
                 Spacer()
             }

From 7ad2c174b8c0786858bfce09513050439a3c9b76 Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Tue, 10 Oct 2023 11:58:17 +0100
Subject: [PATCH 02/10] Make login button functional

---
 MobileAcebook/LogInView.swift | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
index ffc120ba..aefb9673 100644
--- a/MobileAcebook/LogInView.swift
+++ b/MobileAcebook/LogInView.swift
@@ -9,13 +9,20 @@ import Foundation
 import SwiftUI
 import Combine
 
+
 struct LogInView: View {
     @State private var userModel = User(email: "", password: "")
     
     private func onEmailInputChanged(changedEmail: String) {
-            print("-----> in onEmailInputChanged: \(changedEmail) ")
+        userModel.email = changedEmail
+        print("changed email: \(userModel.email)")
         }
     
+    private func onPasswordInputChanged(changedPassword: String) {
+        userModel.password = changedPassword
+        print("changed password: \(userModel.password)")
+        }
+    let authenticationService = AuthenticationService()
     var body: some View {
         
         ZStack {
@@ -30,17 +37,25 @@ struct LogInView: View {
                     .accessibilityIdentifier("makers-logo")
                 
                 Spacer()
+                LabeledContent {
+                  TextField("Email", text: $userModel.email)
+                } label: {
+                  Text("Email")
+                }.onChange(of: userModel.email, perform: onEmailInputChanged)
+                
+                LabeledContent {
+                  TextField("Password", text: $userModel.password)
+                } label: {
+                  Text("Password")
+                }.onChange(of: userModel.password, perform: onPasswordInputChanged)
                 
-                TextField("Email", text: $userModel.email)
-                     .onChange(of: userModel.email, perform: onEmailInputChanged)
                 
-                NavigationLink(destination: LogInView()) {
-                    Text("Login")
-                        .padding()
-                        .background(Color.blue)
-                        .foregroundColor(Color.white)
-                        .cornerRadius(10)
+                Button(action: {authenticationService.login(user: userModel)}) {
+                    // TODO: login logic
+                    Text("login")
+                   
                 }
+                .accessibilityIdentifier("LoginButton")
                 
                 Button("Sign Up") {
                     // TODO: sign up logic

From 47b9b55d129632fed8c1c929d1033ce8211d330c Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Tue, 10 Oct 2023 11:58:49 +0100
Subject: [PATCH 03/10] Allow user to inherit encodable

---
 MobileAcebook/Models/User.swift | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MobileAcebook/Models/User.swift b/MobileAcebook/Models/User.swift
index 04d3a36c..c4835094 100644
--- a/MobileAcebook/Models/User.swift
+++ b/MobileAcebook/Models/User.swift
@@ -5,7 +5,7 @@
 //  Created by Josué Estévez Fernández on 01/10/2023.
 //
 
-public struct User {
+public struct User: Encodable {
     var email: String
     var password: String
 }

From ae8bc9ca6721c03683588a036242ca4cee51eb15 Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Tue, 10 Oct 2023 11:59:19 +0100
Subject: [PATCH 04/10] Implement login function

---
 .../Services/AuthenticationService.swift      | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift
index 9f7181c3..7c186ef7 100644
--- a/MobileAcebook/Services/AuthenticationService.swift
+++ b/MobileAcebook/Services/AuthenticationService.swift
@@ -4,10 +4,44 @@
 //
 //  Created by Josué Estévez Fernández on 01/10/2023.
 //
+import Foundation
 
 class AuthenticationService: AuthenticationServiceProtocol {
     func signUp(user: User) -> Bool {
         // Logic to call the backend API for signing up
         return true // placeholder
     }
+    func login(user: User) -> String {
+        
+        var request = URLRequest(url: URL(string: "http://localhost:8080/tokens")!)
+        request.httpMethod = "POST"
+        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
+
+        let jsonEncoder = JSONEncoder()
+        do {
+            let jsonData = try jsonEncoder.encode(user)
+            request.httpBody = jsonData
+
+            let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
+                // Handle response here
+                if let error = error {
+                    print("Error: \(error)")
+                } else if let data = data {
+                    do {
+                        let jsonResponse = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
+                        print("Response: \(jsonResponse)")
+                    } catch {
+                        print("Error parsing JSON: \(error)")
+                    }
+                }
+            }
+            task.resume()
+        } catch {
+            print("Error encoding user object: \(error)")
+        }
+        return "test"
+//
+    }
+    
+    
 }

From b6af73aba67de8057ebd3d37177994aa7739c4dd Mon Sep 17 00:00:00 2001
From: Ami Day <amiday@Amis-MacBook-Pro-2.local>
Date: Tue, 10 Oct 2023 14:21:13 +0100
Subject: [PATCH 05/10] Updated login so that navigation works

---
 MobileAcebook/LogInView.swift                 | 101 ++++++++++--------
 .../Services/AuthenticationService.swift      |   4 +-
 2 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
index aefb9673..3890421e 100644
--- a/MobileAcebook/LogInView.swift
+++ b/MobileAcebook/LogInView.swift
@@ -12,65 +12,72 @@ import Combine
 
 struct LogInView: View {
     @State private var userModel = User(email: "", password: "")
+    @State private var loggedIn = false
     
     private func onEmailInputChanged(changedEmail: String) {
         userModel.email = changedEmail
         print("changed email: \(userModel.email)")
-        }
+    }
     
     private func onPasswordInputChanged(changedPassword: String) {
         userModel.password = changedPassword
         print("changed password: \(userModel.password)")
-        }
+    }
     let authenticationService = AuthenticationService()
     var body: some View {
-        
-        ZStack {
-            VStack {
-                
-                Spacer()
-                
-                Image("makers-logo")
-                    .resizable()
-                    .scaledToFit()
-                    .frame(width: 200, height: 200)
-                    .accessibilityIdentifier("makers-logo")
-                
-                Spacer()
-                LabeledContent {
-                  TextField("Email", text: $userModel.email)
-                } label: {
-                  Text("Email")
-                }.onChange(of: userModel.email, perform: onEmailInputChanged)
-                
-                LabeledContent {
-                  TextField("Password", text: $userModel.password)
-                } label: {
-                  Text("Password")
-                }.onChange(of: userModel.password, perform: onPasswordInputChanged)
-                
-                
-                Button(action: {authenticationService.login(user: userModel)}) {
-                    // TODO: login logic
-                    Text("login")
-                   
-                }
-                .accessibilityIdentifier("LoginButton")
-                
-                Button("Sign Up") {
-                    // TODO: sign up logic
+        NavigationView {
+            ZStack {
+                VStack {
+                    
+                    Spacer()
+                    
+                    Image("makers-logo")
+                        .resizable()
+                        .scaledToFit()
+                        .frame(width: 200, height: 200)
+                        .accessibilityIdentifier("makers-logo")
+                    
+                    Spacer()
+                    LabeledContent {
+                        TextField("Email", text: $userModel.email)
+                    } label: {
+                        Text("Email")
+                    }.onChange(of: userModel.email, perform: onEmailInputChanged)
+                    
+                    LabeledContent {
+                        TextField("Password", text: $userModel.password)
+                    } label: {
+                        Text("Password")
+                    }.onChange(of: userModel.password, perform: onPasswordInputChanged)
+                    
+                    
+                    Button(action: {
+                        var response = authenticationService.login(user: userModel)
+                        if response == true {
+                            loggedIn = true
+                        }
+                    }) {
+                        Text("Login")
+                    }
+                    .accessibilityIdentifier("LoginButton")
+                    
+                    NavigationLink(destination: WelcomePageView(), isActive: $loggedIn) { EmptyView() }
+                    
+                    Button("Sign Up") {
+                        // TODO: sign up logic
+                    }
+                    .accessibilityIdentifier("signUpButton")
+                    
                 }
-                .accessibilityIdentifier("signUpButton")
                 
+                Spacer()
             }
-            
-            Spacer()
         }
-            }
+    }
+    
+    struct LogInView_Previews: PreviewProvider {
+        static var previews: some View {
+            LogInView()
         }
-
-struct LogInView_Previews: PreviewProvider {
-                    static var previews: some View {
-                        LogInView()
-                    }
-                }
+    }
+}
diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift
index 7c186ef7..f66de43d 100644
--- a/MobileAcebook/Services/AuthenticationService.swift
+++ b/MobileAcebook/Services/AuthenticationService.swift
@@ -11,7 +11,7 @@ class AuthenticationService: AuthenticationServiceProtocol {
         // Logic to call the backend API for signing up
         return true // placeholder
     }
-    func login(user: User) -> String {
+    func login(user: User) -> Bool {
         
         var request = URLRequest(url: URL(string: "http://localhost:8080/tokens")!)
         request.httpMethod = "POST"
@@ -39,7 +39,7 @@ class AuthenticationService: AuthenticationServiceProtocol {
         } catch {
             print("Error encoding user object: \(error)")
         }
-        return "test"
+        return true
 //
     }
     

From c76d6544e78eaa3686535bc1ac780670d8c16c70 Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Wed, 11 Oct 2023 10:26:21 +0100
Subject: [PATCH 06/10] Modify btn function

---
 MobileAcebook/LogInView.swift | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
index 3890421e..8ac4f66d 100644
--- a/MobileAcebook/LogInView.swift
+++ b/MobileAcebook/LogInView.swift
@@ -52,9 +52,10 @@ struct LogInView: View {
                     
                     
                     Button(action: {
-                        var response = authenticationService.login(user: userModel)
-                        if response == true {
-                            loggedIn = true
+                        var response = authenticationService.login(user: userModel) { isSuccess in
+                            if isSuccess {
+                                loggedIn = true
+                            }
                         }
                     }) {
                         Text("Login")

From 620b1dcb5f74724c6e63c659a4579f8662d2e90d Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Wed, 11 Oct 2023 10:26:39 +0100
Subject: [PATCH 07/10] Modify login function

---
 .../Services/AuthenticationService.swift      | 78 +++++++++++++++++--
 1 file changed, 70 insertions(+), 8 deletions(-)

diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift
index f66de43d..3a97b163 100644
--- a/MobileAcebook/Services/AuthenticationService.swift
+++ b/MobileAcebook/Services/AuthenticationService.swift
@@ -11,8 +11,8 @@ class AuthenticationService: AuthenticationServiceProtocol {
         // Logic to call the backend API for signing up
         return true // placeholder
     }
-    func login(user: User) -> Bool {
-        
+    
+    func login(user: User, completion: @escaping (Bool) -> Void) {
         var request = URLRequest(url: URL(string: "http://localhost:8080/tokens")!)
         request.httpMethod = "POST"
         request.setValue("application/json", forHTTPHeaderField: "Content-Type")
@@ -23,25 +23,87 @@ class AuthenticationService: AuthenticationServiceProtocol {
             request.httpBody = jsonData
 
             let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
-                // Handle response here
-                if let error = error {
-                    print("Error: \(error)")
-                } else if let data = data {
+                // Handling the response data, if any
+                var isSuccess = false
+
+                if let data = data {
                     do {
                         let jsonResponse = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
                         print("Response: \(jsonResponse)")
+
+                        if let message = jsonResponse?["message"] as? String, message == "OK" {
+                            // If the response message is "Email not found", login is unsuccessful
+                            isSuccess = true
+                        }
                     } catch {
+                        // Handle JSON parsing errors, if any
                         print("Error parsing JSON: \(error)")
                     }
                 }
+
+                // Calling the completion handler with the login result (true for successful, false for unsuccessful)
+                completion(isSuccess)
             }
+
             task.resume()
         } catch {
+            // Handle encoding errors, if any
             print("Error encoding user object: \(error)")
+            completion(false) // Calling the completion handler with false in case of an error
         }
-        return true
-//
     }
+
+    
     
+//    func login(user: User) -> Bool {
+//        
+//        var request = URLRequest(url: URL(string: "http://localhost:8080/tokens")!)
+//        request.httpMethod = "POST"
+//        var res: [String: Any]? = ["message": ""]
+//        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
+//        var ans = false
+//
+//        let jsonEncoder = JSONEncoder()
+//        do {
+//            let jsonData = try jsonEncoder.encode(user)
+//            request.httpBody = jsonData
+//
+//            let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
+//                // Handle response here
+//                
+//                 if let data = data {
+//                    do {
+//                        let jsonResponse = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
+//                        print("Response: \(jsonResponse)")
+//                        res = jsonResponse
+//                        
+//                        
+//                    } catch {
+//                        print("Error parsing JSON: \(error)")
+//                    }
+//                    
+//                }
+//            }
+//    
+//            task.resume()
+//        } catch {
+//            print("Error encoding user object: \(error)")
+//            
+//        }
+//        return ans
+//        
+//        if let message = res?["message"] as? String, message == "Email not found" {
+//            print("yhukh")
+//            return false
+//        }else {
+//            print(res?["message"])
+//            print("working")
+//            return true
+//        }
+//        
+//      
+////
+//    }
+//    
     
 }

From 6f1e862c079fabdbade6ff3b0899bc598164801c Mon Sep 17 00:00:00 2001
From: Ami Day <amiday@Amis-MacBook-Pro-2.local>
Date: Wed, 11 Oct 2023 10:33:19 +0100
Subject: [PATCH 08/10] Fixed autocapitalization, finished login functionality

---
 MobileAcebook/LogInView.swift | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
index 8ac4f66d..83af0683 100644
--- a/MobileAcebook/LogInView.swift
+++ b/MobileAcebook/LogInView.swift
@@ -39,13 +39,13 @@ struct LogInView: View {
                     
                     Spacer()
                     LabeledContent {
-                        TextField("Email", text: $userModel.email)
+                        TextField("Email", text: $userModel.email).textInputAutocapitalization(.never)
                     } label: {
                         Text("Email")
                     }.onChange(of: userModel.email, perform: onEmailInputChanged)
                     
                     LabeledContent {
-                        TextField("Password", text: $userModel.password)
+                        TextField("Password", text: $userModel.password).textInputAutocapitalization(.never)
                     } label: {
                         Text("Password")
                     }.onChange(of: userModel.password, perform: onPasswordInputChanged)
@@ -62,7 +62,7 @@ struct LogInView: View {
                     }
                     .accessibilityIdentifier("LoginButton")
                     
-                    NavigationLink(destination: WelcomePageView(), isActive: $loggedIn) { EmptyView() }
+                    NavigationLink(destination: WelcomePageView().navigationBarBackButtonHidden(true), isActive: $loggedIn) { EmptyView() }
                     
                     Button("Sign Up") {
                         // TODO: sign up logic

From 8135278627b938d10285ac6ec044906d8da0db58 Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Wed, 11 Oct 2023 11:48:02 +0100
Subject: [PATCH 09/10] Add a token var

---
 .../Services/AuthenticationService.swift          | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift
index 3a97b163..e266d6f8 100644
--- a/MobileAcebook/Services/AuthenticationService.swift
+++ b/MobileAcebook/Services/AuthenticationService.swift
@@ -7,6 +7,11 @@
 import Foundation
 
 class AuthenticationService: AuthenticationServiceProtocol {
+    var userToken: String?
+  
+    
+
+    
     func signUp(user: User) -> Bool {
         // Logic to call the backend API for signing up
         return true // placeholder
@@ -25,6 +30,7 @@ class AuthenticationService: AuthenticationServiceProtocol {
             let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
                 // Handling the response data, if any
                 var isSuccess = false
+                var token: String? = nil
 
                 if let data = data {
                     do {
@@ -34,9 +40,15 @@ class AuthenticationService: AuthenticationServiceProtocol {
                         if let message = jsonResponse?["message"] as? String, message == "OK" {
                             // If the response message is "Email not found", login is unsuccessful
                             isSuccess = true
+                            if let token = jsonResponse?["token"] as? String {
+                                                        // Store the token in a variable
+                                self.userToken = token
+                                print(self.userToken)
+                                                    }
                         }
+                        
                     } catch {
-                        // Handle JSON parsing errors, if any
+                                   // Handle JSON parsing errors, if any
                         print("Error parsing JSON: \(error)")
                     }
                 }
@@ -52,7 +64,6 @@ class AuthenticationService: AuthenticationServiceProtocol {
             completion(false) // Calling the completion handler with false in case of an error
         }
     }
-
     
     
 //    func login(user: User) -> Bool {

From 1b216ff0aa3839a792760767115162f2fccd8d4c Mon Sep 17 00:00:00 2001
From: nayan0499 <nayangrg.uni@gmail.com>
Date: Wed, 11 Oct 2023 12:59:51 +0100
Subject: [PATCH 10/10] Merge posts_page branch

---
 MobileAcebook.xcodeproj/project.pbxproj |  8 ++++
 MobileAcebook/LogInView.swift           |  2 +-
 MobileAcebook/Models/Post.swift         | 10 +++++
 MobileAcebook/PostsView.swift           | 59 +++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 MobileAcebook/Models/Post.swift
 create mode 100644 MobileAcebook/PostsView.swift

diff --git a/MobileAcebook.xcodeproj/project.pbxproj b/MobileAcebook.xcodeproj/project.pbxproj
index e7c60367..173677cd 100644
--- a/MobileAcebook.xcodeproj/project.pbxproj
+++ b/MobileAcebook.xcodeproj/project.pbxproj
@@ -8,6 +8,8 @@
 
 /* Begin PBXBuildFile section */
 		10D70DA82AD44C30003B552B /* LogInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D70DA72AD44C30003B552B /* LogInView.swift */; };
+		9105C5752AD6C3BB00ABFC89 /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9105C5742AD6C3BB00ABFC89 /* Post.swift */; };
+		9105C5772AD6C3C600ABFC89 /* PostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9105C5762AD6C3C600ABFC89 /* PostsView.swift */; };
 		AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */; };
 		AE5D85B42AC8A224009680C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B32AC8A224009680C6 /* Assets.xcassets */; };
 		AE5D85B72AC8A224009680C6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE5D85B62AC8A224009680C6 /* Preview Assets.xcassets */; };
@@ -41,6 +43,8 @@
 
 /* Begin PBXFileReference section */
 		10D70DA72AD44C30003B552B /* LogInView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInView.swift; sourceTree = "<group>"; };
+		9105C5742AD6C3BB00ABFC89 /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
+		9105C5762AD6C3C600ABFC89 /* PostsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostsView.swift; sourceTree = "<group>"; };
 		AE5D85AC2AC8A221009680C6 /* MobileAcebook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileAcebook.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		AE5D85AF2AC8A221009680C6 /* MobileAcebookApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileAcebookApp.swift; sourceTree = "<group>"; };
 		AE5D85B32AC8A224009680C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -106,6 +110,7 @@
 		AE5D85AE2AC8A221009680C6 /* MobileAcebook */ = {
 			isa = PBXGroup;
 			children = (
+				9105C5762AD6C3C600ABFC89 /* PostsView.swift */,
 				AE5D85E42AC9B060009680C6 /* Protocols */,
 				AE5D85DF2AC9AF83009680C6 /* Models */,
 				AE5D85DD2AC9AF72009680C6 /* Services */,
@@ -164,6 +169,7 @@
 		AE5D85DF2AC9AF83009680C6 /* Models */ = {
 			isa = PBXGroup;
 			children = (
+				9105C5742AD6C3BB00ABFC89 /* Post.swift */,
 				AE5D85E72AC9B29A009680C6 /* User.swift */,
 			);
 			path = Models;
@@ -312,6 +318,8 @@
 				AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */,
 				AE5D85B02AC8A221009680C6 /* MobileAcebookApp.swift in Sources */,
 				AE5D85E82AC9B29A009680C6 /* User.swift in Sources */,
+				9105C5752AD6C3BB00ABFC89 /* Post.swift in Sources */,
+				9105C5772AD6C3C600ABFC89 /* PostsView.swift in Sources */,
 				AE5D85DA2AC8A337009680C6 /* WelcomePageView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
diff --git a/MobileAcebook/LogInView.swift b/MobileAcebook/LogInView.swift
index 83af0683..6c97cf4e 100644
--- a/MobileAcebook/LogInView.swift
+++ b/MobileAcebook/LogInView.swift
@@ -62,7 +62,7 @@ struct LogInView: View {
                     }
                     .accessibilityIdentifier("LoginButton")
                     
-                    NavigationLink(destination: WelcomePageView().navigationBarBackButtonHidden(true), isActive: $loggedIn) { EmptyView() }
+                    NavigationLink(destination: PostsView().navigationBarBackButtonHidden(true), isActive: $loggedIn) { EmptyView() }
                     
                     Button("Sign Up") {
                         // TODO: sign up logic
diff --git a/MobileAcebook/Models/Post.swift b/MobileAcebook/Models/Post.swift
new file mode 100644
index 00000000..b256b217
--- /dev/null
+++ b/MobileAcebook/Models/Post.swift
@@ -0,0 +1,10 @@
+//
+//  Post.swift
+//  MobileAcebook
+//
+//  Created by Jenny Wark on 11/10/2023.
+//
+
+public struct Post {
+    let message: String
+}
diff --git a/MobileAcebook/PostsView.swift b/MobileAcebook/PostsView.swift
new file mode 100644
index 00000000..23a47f73
--- /dev/null
+++ b/MobileAcebook/PostsView.swift
@@ -0,0 +1,59 @@
+//
+//  PostsView.swift
+//  MobileAcebook
+//
+//  Created by Jenny Wark on 11/10/2023.
+//
+
+import SwiftUI
+
+struct PostsView: View {
+    @State private var authenticationService = AuthenticationService()
+    @State private var post_content: String = ""
+    var body: some View {
+        NavigationView {
+            VStack {
+                Spacer()
+                
+                Text("Posts")
+                    .font(.largeTitle)
+                    .padding(.bottom, 20)
+                    .accessibilityIdentifier("welcomeText")
+                
+                Spacer()
+                
+                Image("makers-logo")
+                    .resizable()
+                    .scaledToFit()
+                    .frame(width: 200, height: 200)
+                    .accessibilityIdentifier("makers-logo")
+                
+                Spacer()
+                
+                TextField("Write a post", text: $post_content)
+                    .textFieldStyle(RoundedBorderTextFieldStyle())
+                    .padding()
+                
+//                Button(action: {
+//                    authenticationService.createPost(post: Post(message: post_content))
+//                }) {
+//                    Text("Create Post")
+//                }
+//                .accessibilityIdentifier("CreatePostButton")
+                
+                Spacer()
+                
+//                let Posts = authenticationService.allPosts
+                
+                Spacer()
+                
+            }
+        }
+  }
+}
+
+struct PostsView_Previews: PreviewProvider {
+  static var previews: some View {
+    PostsView()
+  }
+}