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

Link sign up page #47

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f588bb2
Testing branch creation and pushing via Xcode.
bogdans13 Apr 16, 2024
d5f2c31
First commit - signup function added to AuthenticationService.swift.…
Maria-Basia Apr 16, 2024
0355fb0
login page created
ttyhktup Apr 16, 2024
2c481f3
added post model, aand also changed the welcome page
Jessicacktodd Apr 16, 2024
32e21a9
.DS_Store file added to .gitignore file
Maria-Basia Apr 16, 2024
1f17a2f
deleted .DS_Store file and removed not needed comments
Maria-Basia Apr 16, 2024
787e452
removed DS_Store added DS_Store to gitignore to avoid future pushes
George-Paul-1 Apr 16, 2024
5085729
Merge branch 'main' into services_authentication
Maria-Basia Apr 16, 2024
490ce94
playing around with button sizes
Jessicacktodd Apr 16, 2024
aedc0a1
Merge pull request #2 from bogdans13/services_authentication
ttyhktup Apr 16, 2024
9782224
commit it all
ttyhktup Apr 16, 2024
8cacb5f
DSSTOREREMOVED
ttyhktup Apr 16, 2024
c52738b
deleted DS_Store
Jessicacktodd Apr 16, 2024
3c9935d
Merge pull request #3 from bogdans13/create_login
ttyhktup Apr 16, 2024
1169c1e
got rid of merge conflicts
Jessicacktodd Apr 16, 2024
8cd3aa4
Merge pull request #4 from bogdans13/postModel
Jessicacktodd Apr 16, 2024
e7ed366
let's try
ttyhktup Apr 16, 2024
d66635f
Merge pull request #6 from bogdans13/create_login
ttyhktup Apr 16, 2024
0a2b056
login and signup style
ttyhktup Apr 17, 2024
6eb5044
first logic changes
ohmygois Apr 17, 2024
527317a
Merge branch 'create_login' of https://github.com/bogdans13/swiftui-e…
ohmygois Apr 17, 2024
9219017
signup page final
ttyhktup Apr 17, 2024
ba9a4f9
all pages styles alligned
ttyhktup Apr 17, 2024
336f533
Create Post Service + assign :Encodable to Post [Model]
bogdans13 Apr 17, 2024
1a1db21
changes made
ohmygois Apr 17, 2024
384f8df
changes made
ohmygois Apr 17, 2024
6989292
login function and UserLogin model added
Maria-Basia Apr 17, 2024
4b2054e
Merge pull request #7 from bogdans13/post_route
ohmygois Apr 17, 2024
12d4847
some changes
ttyhktup Apr 18, 2024
0434b60
Merge pull request #9 from bogdans13/create_login
ttyhktup Apr 18, 2024
b58c034
Merge branch 'main' into authentication
ttyhktup Apr 18, 2024
f2881ec
Merge pull request #8 from bogdans13/authentication
ttyhktup Apr 18, 2024
b0486fb
welcome page links added
ttyhktup Apr 18, 2024
b8f988a
Merge pull request #10 from bogdans13/create_login
ttyhktup Apr 18, 2024
fc2b204
autocapitalization removed
ttyhktup Apr 18, 2024
fd0d0e4
Merge pull request #11 from bogdans13/create_login
ttyhktup Apr 18, 2024
95ad1e8
signup working
ttyhktup Apr 18, 2024
bddf4de
Merge pull request #12 from bogdans13/create_login
ttyhktup Apr 18, 2024
83b1f6e
changes made
ohmygois Apr 18, 2024
9e51082
Latest version
ohmygois Apr 18, 2024
c25af4c
Merge pull request #13 from bogdans13/SignUpLogic
ohmygois Apr 18, 2024
67c151f
logging in added
ttyhktup Apr 18, 2024
9d4b7f2
Merge branch 'main' of https://github.com/bogdans13/swiftui-engineeri…
ttyhktup Apr 18, 2024
a9b71ab
logging in with main
ttyhktup Apr 18, 2024
e180cf7
Merge pull request #14 from bogdans13/create_login
ttyhktup Apr 18, 2024
4f9a303
feedPage - no logic yet
Jessicacktodd Apr 18, 2024
b7985d4
Merge pull request #15 from bogdans13/feedPage
Jessicacktodd Apr 18, 2024
5d0ca8d
signUp function fixed and signUp button on signup page calls signUp a…
Maria-Basia Apr 18, 2024
9438d50
signup button calls signup and provides feedback and signup function …
Maria-Basia Apr 18, 2024
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
Prev Previous commit
Next Next commit
Create Post Service + assign :Encodable to Post [Model]
 - created Post Service file: with /POST request - /GET request to add later
- slight modification to the Post model to assign Encodable type due to JSON data needing to be in encoded format
bogdans13 committed Apr 17, 2024
commit 336f533dcf65a5cb396492083bb19fcfd2c589d5
4 changes: 4 additions & 0 deletions MobileAcebook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
AE5D85E32AC9AFD2009680C6 /* MockAuthenticationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E22AC9AFD2009680C6 /* MockAuthenticationService.swift */; };
AE5D85E62AC9B077009680C6 /* AuthenticationServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E52AC9B077009680C6 /* AuthenticationServiceProtocol.swift */; };
AE5D85E82AC9B29A009680C6 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5D85E72AC9B29A009680C6 /* User.swift */; };
C1615B992BCFEF2800A7AB81 /* PostService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1615B982BCFEF2800A7AB81 /* PostService.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
@@ -60,6 +61,7 @@
AE5D85E22AC9AFD2009680C6 /* MockAuthenticationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAuthenticationService.swift; sourceTree = "<group>"; };
AE5D85E52AC9B077009680C6 /* AuthenticationServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationServiceProtocol.swift; sourceTree = "<group>"; };
AE5D85E72AC9B29A009680C6 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
C1615B982BCFEF2800A7AB81 /* PostService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostService.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -154,6 +156,7 @@
isa = PBXGroup;
children = (
AE5D85E02AC9AFA9009680C6 /* AuthenticationService.swift */,
C1615B982BCFEF2800A7AB81 /* PostService.swift */,
);
path = Services;
sourceTree = "<group>";
@@ -320,6 +323,7 @@
AE5D85E82AC9B29A009680C6 /* User.swift in Sources */,
0F81A0C72BCED6FD00AED673 /* SignUpPageView.swift in Sources */,
AE5D85DA2AC8A337009680C6 /* WelcomePageView.swift in Sources */,
C1615B992BCFEF2800A7AB81 /* PostService.swift in Sources */,
0F81A0C52BCE82C200AED673 /* LoginPageView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
2 changes: 1 addition & 1 deletion MobileAcebook/Models/Post.swift
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

import Foundation

public struct Post {
public struct Post: Encodable {
let message: String
let date: String
let user: String
58 changes: 58 additions & 0 deletions MobileAcebook/Services/PostService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// PostService.swift
// MobileAcebook
//
// Created by Bogdan Stăiculescu on 17/04/2024.
//

import Foundation

class postService {

// response returned on succesful /POST request
struct Response: Codable {
// let message : String
let token: String
}


func createPost(post: Post, token: String, completion: @escaping ((String) -> Void)) -> Bool {
// defining URL to which we make the POST on the Backend
guard let url = URL(string: "http://localhost:3000/posts") else
{return false}

// var that contains the URL request and content
var urlRequest = URLRequest(url: url)
// method of the createPost
urlRequest.httpMethod = "POST"
// value of the URL request that's being sent to backend [application/json]
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
// also passing along Bearer and Token to show authorization
urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")

// defining the body of the HTTP request
let body = post

urlRequest.httpBody = try? JSONEncoder().encode(body)

// defining what we do with the response of our request
let task = URLSession.shared.dataTask(with: urlRequest) {data, response, error in
// ensures there is data that returns after making the request ELSE print error
guard let data = data else {return}
// if there is data
do {
let response = try JSONDecoder().decode(Response.self, from: data)
//print(response.token)
DispatchQueue.main.async {
completion(response.token)
}
print("Post Created")
}
catch {
print(error)
}
}
task.resume()
return true
}
}