Skip to content
Open
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
36 changes: 26 additions & 10 deletions SinuS/SinuS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
4A32753E298AE46A009D1CC8 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = 4A32753D298AE46A009D1CC8 /* FirebaseDatabase */; };
4A327540298AE46A009D1CC8 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 4A32753F298AE46A009D1CC8 /* FirebaseMessaging */; };
4A327542298AE46A009D1CC8 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 4A327541298AE46A009D1CC8 /* FirebaseStorage */; };
4A4C6D002917C2E4001DB4F7 /* AuthenticationStartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4C6CFF2917C2E4001DB4F7 /* AuthenticationStartView.swift */; };
4A327547298EA697009D1CC8 /* PreAuthenticationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A327546298EA697009D1CC8 /* PreAuthenticationView.swift */; };
4A4C6D032917C2F9001DB4F7 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4C6D022917C2F9001DB4F7 /* LoginView.swift */; };
4A4C6D062917C30D001DB4F7 /* RegisterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4C6D052917C30D001DB4F7 /* RegisterView.swift */; };
4A4C6D082917CD95001DB4F7 /* AuthenticationResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4C6D072917CD95001DB4F7 /* AuthenticationResult.swift */; };
Expand Down Expand Up @@ -63,6 +63,10 @@
CE6A64E629696C1C00DC47E5 /* SwiftKeychainWrapper in Frameworks */ = {isa = PBXBuildFile; productRef = CE6A64E529696C1C00DC47E5 /* SwiftKeychainWrapper */; };
CE89A8762969F93200300C9D /* ManageProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE89A8752969F93200300C9D /* ManageProfileView.swift */; };
CE89A87A296AF2D300300C9D /* LogHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE89A879296AF2D300300C9D /* LogHelper.swift */; };
CEECA4FD29709E0F00CA4496 /* ForgotPasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEECA4FC29709E0F00CA4496 /* ForgotPasswordView.swift */; };
CEECA4FF2974534700CA4496 /* ResetPasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEECA4FE2974534700CA4496 /* ResetPasswordView.swift */; };
CEECA5012974665800CA4496 /* VerifyEmailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEECA5002974665800CA4496 /* VerifyEmailView.swift */; };
CEECA50329748DA600CA4496 /* ClickResetPasswordLinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEECA50229748DA600CA4496 /* ClickResetPasswordLinkView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -101,8 +105,7 @@
4A32752829772B0A009D1CC8 /* WaveMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveMenuView.swift; sourceTree = "<group>"; };
4A32752A29773236009D1CC8 /* CompareButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompareButtonView.swift; sourceTree = "<group>"; };
4A32752C297D4B6E009D1CC8 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
4A327537298AE0F5009D1CC8 /* SinuS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SinuS.entitlements; sourceTree = "<group>"; };
4A4C6CFF2917C2E4001DB4F7 /* AuthenticationStartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationStartView.swift; sourceTree = "<group>"; };
4A327546298EA697009D1CC8 /* PreAuthenticationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreAuthenticationView.swift; sourceTree = "<group>"; };
4A4C6D022917C2F9001DB4F7 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
4A4C6D052917C30D001DB4F7 /* RegisterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterView.swift; sourceTree = "<group>"; };
4A4C6D072917CD95001DB4F7 /* AuthenticationResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationResult.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,6 +143,11 @@
4AD26FF428C7BFC10065FB01 /* DataGatherer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataGatherer.swift; sourceTree = "<group>"; };
CE89A8752969F93200300C9D /* ManageProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageProfileView.swift; sourceTree = "<group>"; };
CE89A879296AF2D300300C9D /* LogHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogHelper.swift; sourceTree = "<group>"; };
CEECA4FC29709E0F00CA4496 /* ForgotPasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForgotPasswordView.swift; sourceTree = "<group>"; };
CEECA4FE2974534700CA4496 /* ResetPasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetPasswordView.swift; sourceTree = "<group>"; };
CEECA5002974665800CA4496 /* VerifyEmailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifyEmailView.swift; sourceTree = "<group>"; };
CEECA50229748DA600CA4496 /* ClickResetPasswordLinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClickResetPasswordLinkView.swift; sourceTree = "<group>"; };
CEECA5042974928C00CA4496 /* SinuSRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SinuSRelease.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -207,9 +215,13 @@
4A4C6CFE2917C2A8001DB4F7 /* Authentication */ = {
isa = PBXGroup;
children = (
4A4C6CFF2917C2E4001DB4F7 /* AuthenticationStartView.swift */,
4A4C6D022917C2F9001DB4F7 /* LoginView.swift */,
4A4C6D052917C30D001DB4F7 /* RegisterView.swift */,
CEECA4FC29709E0F00CA4496 /* ForgotPasswordView.swift */,
CEECA4FE2974534700CA4496 /* ResetPasswordView.swift */,
CEECA5002974665800CA4496 /* VerifyEmailView.swift */,
CEECA50229748DA600CA4496 /* ClickResetPasswordLinkView.swift */,
4A327546298EA697009D1CC8 /* PreAuthenticationView.swift */,
);
path = Authentication;
sourceTree = "<group>";
Expand Down Expand Up @@ -308,7 +320,7 @@
4AD26FB828BBA5D40065FB01 /* SinuS */ = {
isa = PBXGroup;
children = (
4A327537298AE0F5009D1CC8 /* SinuS.entitlements */,
CEECA5042974928C00CA4496 /* SinuSRelease.entitlements */,
4AC5B3DD296AD537003D819C /* Style */,
4AD26FE928BBAE930065FB01 /* Data */,
4AD26FE428BBA8C40065FB01 /* Views */,
Expand Down Expand Up @@ -552,7 +564,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A4C6D002917C2E4001DB4F7 /* AuthenticationStartView.swift in Sources */,
CEECA5012974665800CA4496 /* VerifyEmailView.swift in Sources */,
CEECA4FF2974534700CA4496 /* ResetPasswordView.swift in Sources */,
4A32752B29773236009D1CC8 /* CompareButtonView.swift in Sources */,
4AC5B3E5296ADE0D003D819C /* TotalUserData.swift in Sources */,
4AD26FEB28BBAEA40065FB01 /* SinusData.swift in Sources */,
Expand All @@ -574,6 +587,8 @@
4A0B397728E06E9600D7EEC9 /* SinusUserData.swift in Sources */,
4AD26FBC28BBA5D40065FB01 /* ContentView.swift in Sources */,
4A0B397428D6044300D7EEC9 /* WaveView.swift in Sources */,
CEECA4FD29709E0F00CA4496 /* ForgotPasswordView.swift in Sources */,
4A0B397428D6044300D7EEC9 /* WaveView.swift in Sources */,
4AC5B3D529698525003D819C /* PersonalView.swift in Sources */,
4A0B396A28D38DE000D7EEC9 /* MenuView.swift in Sources */,
4A4C6D062917C30D001DB4F7 /* RegisterView.swift in Sources */,
Expand All @@ -591,9 +606,11 @@
4A4C6D082917CD95001DB4F7 /* AuthenticationResult.swift in Sources */,
4A4C6D032917C2F9001DB4F7 /* LoginView.swift in Sources */,
4A0B397B28E0846900D7EEC9 /* RelationStatusView.swift in Sources */,
4A327547298EA697009D1CC8 /* PreAuthenticationView.swift in Sources */,
4AC5B3E3296ADB51003D819C /* UserData.swift in Sources */,
4AD26FBA28BBA5D40065FB01 /* SinuSApp.swift in Sources */,
4AC5B3D3296849DD003D819C /* RestApiHelper.swift in Sources */,
CEECA50329748DA600CA4496 /* ClickResetPasswordLinkView.swift in Sources */,
4AD26FF128C6773E0065FB01 /* FeedWaveView.swift in Sources */,
4AD26FED28C676C10065FB01 /* LineChart.swift in Sources */,
4A0B396E28D3935900D7EEC9 /* NewWaveView.swift in Sources */,
Expand Down Expand Up @@ -753,11 +770,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = SinuS/SinuS.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"SinuS/Preview Content\"";
DEVELOPMENT_TEAM = 479GB76B7L;
DEVELOPMENT_TEAM = 27MSAG6A3N;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = SinuS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -778,11 +794,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = SinuS/SinuS.entitlements;
CODE_SIGN_ENTITLEMENTS = SinuS/SinuSRelease.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"SinuS/Preview Content\"";
DEVELOPMENT_TEAM = 479GB76B7L;
DEVELOPMENT_TEAM = 27MSAG6A3N;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = SinuS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand Down
27 changes: 24 additions & 3 deletions SinuS/SinuS/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ struct ContentView: View {

var body: some View {
NavigationView {
if KeychainWrapper.standard.string(forKey: "bearerToken") == nil {
AuthenticationStartView()
} else {
if KeychainWrapper.standard.string(forKey: "bearerToken") == nil {
PreAuthenticationView()
} else {
MenuView()
}
}
Expand All @@ -28,3 +28,24 @@ struct ContentView_Previews: PreviewProvider {
ContentView()
}
}

func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Get URL components from the incoming user activity.
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
return false
}

// Check for specific URL components that you need.
guard let path = components.path,
let params = components.queryItems else {
return false
}
print("path = \(path)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove debug print


// Dispatch event to trigger another view
return true
}
61 changes: 61 additions & 0 deletions SinuS/SinuS/Data/DataGatherer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,67 @@ public class DataManager {
return result
}

public func forgotPassword(email: String) -> AuthenticationResult? {
let loginUrl = "https://lukassinus2.vanbroeckhuijsenvof.nl/api/forgot-password"
let parameters: [String: Any] = ["email": email]
let decoder = JSONDecoder()
var request = RestApiHelper.createRequest(type: "POST", url: loginUrl, auth: false)

do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
} catch let error {
print(error.localizedDescription)
return nil
}

var result: AuthenticationResult?
let data = RestApiHelper.perfomRestCall(request: request)

do {
result = try decoder.decode(AuthenticationResult.self, from: data!)
} catch {
let returnedData = (String(bytes: data!, encoding: .utf8) ?? "")
let errMsg = "Unable to process forgot password request: \(returnedData)"
self.logHelper.logMsg(level: "error", message: errMsg)
print(errMsg)
}

return result
}

public func resetPassword(token: String, email: String, password: String, confirmPassword: String) -> AuthenticationResult? {
let loginUrl = "https://lukassinus2.vanbroeckhuijsenvof.nl/api/reset-password"
let parameters: [String: Any] = [
"token": token,
"email": email,
"password": password,
"password_confirmation": confirmPassword
]
let decoder = JSONDecoder()
var request = RestApiHelper.createRequest(type: "POST", url: loginUrl, auth: false)

do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
} catch let error {
print(error.localizedDescription)
return nil
}

var result: AuthenticationResult?
let data = RestApiHelper.perfomRestCall(request: request)

do {
result = try decoder.decode(AuthenticationResult.self, from: data!)
} catch {
let returnedData = (String(bytes: data!, encoding: .utf8) ?? "")
let errMsg = "Unable to reset password: \(returnedData)"
self.logHelper.logMsg(level: "error", message: errMsg)
print(errMsg)
}

return result
}

public func getCurrentUser() -> TotalUserData? {
let url = "https://lukassinus2.vanbroeckhuijsenvof.nl/api/user"
let decoder = JSONDecoder()
Expand Down
49 changes: 36 additions & 13 deletions SinuS/SinuS/Views/Authentication/AuthenticationStartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,46 @@
import SwiftUI

struct AuthenticationStartView: View {
var body: some View {
NavigationView {
VStack {
@State private var selection = Tab.feed

Spacer()
private var feedViewModelExplore: FeedViewModel

// Login Button
NavigationLink(destination: LoginView(), label: {
MenuButton(image: Image(systemName: "person.badge.key.fill"), name: "Login")
})
private enum Tab: Hashable {
case feed
case login
case register
}

// Register Button
NavigationLink(destination: RegisterView(), label: {
MenuButton(image: Image(systemName: "person.fill.badge.plus"), name: "Register")
})
init() {
self.feedViewModelExplore = FeedViewModel()
}

var body: some View {
let manager = DataManager()

Spacer()
VStack {
TabView(selection: self.$selection) {
Group {
FeedView(feedViewModel: self.feedViewModelExplore, gatherer: manager, onlyFollowing: false)
.tabItem {
Label("Explore", systemImage: "network")
}
.tag(Tab.feed)
RegisterView()
.tabItem {
Label("Register", systemImage: "person.fill.badge.plus")
}
.tag(Tab.register)
LoginView()
.tabItem {
Label("Login", systemImage: "person.badge.key.fill")
}
.tag(Tab.login)
}
.toolbar(.visible, for: .tabBar)
.toolbarBackground(Style.AppColor, for: .tabBar)
.toolbarBackground(.visible, for: .tabBar)
.toolbarColorScheme(.dark, for: .tabBar)
}
}
}
Expand Down
48 changes: 48 additions & 0 deletions SinuS/SinuS/Views/Authentication/ClickResetPasswordLinkView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// ClickResetPasswordLinkView.swift
// SinuS
//
// Created by Patrick van Broeckhuijsen on 15/01/2023.
//

import SwiftUI

struct ClickResetPasswordLinkView: View {
var body: some View {
VStack {
Spacer()

Text("Please click on the link sent to your email")

Text("Go back")

Spacer()
}
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(Style.AppColor, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .principal) {
VStack {
HStack {
Image(systemName: "water.waves")
.resizable()
.frame(width: 25, height: 25)
.foregroundColor(.white)
.padding(.bottom)
Text("Love Waves")
.foregroundColor(.white)
.font(.system(size: 25))
.padding(.bottom)
}
}
}
}
}
}

struct ClickResetPasswordLinkView_Previews: PreviewProvider {
static var previews: some View {
ClickResetPasswordLinkView()
}
}
Loading