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

mathieu/feature/implement login and signup w/ FirebaseAuthCombine #507

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
85c27ab
:sparkles: (AccountKit): Add Firebase SPM and AuthManager
macteuts Nov 29, 2023
38f3375
:recycle: (AccountKit): Refactor models & UI to use actual Firebase Auth
macteuts Dec 1, 2023
1aa45e5
:sparkles: (AccountKit): Handle SinIn & SignUp errors w/ user alerts
macteuts Dec 1, 2023
c8c2b9e
:bug: (AccountKit): Add ObjC linker & Firebase plist file via Tuist
macteuts Dec 4, 2023
ad7dc5f
:passport_control: (AccountKit): Clean-Up Auth errors & failed auth u…
macteuts Dec 4, 2023
4ecbe5f
:sparkles: (AccountKit): Add ResetPassword case to Auth Operations
macteuts Dec 4, 2023
536a1af
:sparkles: (AccountKit): Add email verification
macteuts Dec 5, 2023
1cc7583
:bug: (AccountKit): Fix Firebase version number
macteuts Dec 5, 2023
620744a
:bug: (AccountKit): Add missing navigation content in MainView
macteuts Dec 5, 2023
cf44adf
:sparkles: (AccountKit): Add email verification & update error handling
macteuts Dec 5, 2023
5b36430
:sparkles: (AccountKit): Add user alerts for all auth events
macteuts Dec 5, 2023
3898d94
:bug: (AccountKit): Fix Strong password cover blocking securefields
macteuts Dec 5, 2023
a2529df
:bug: (AccountKit): Fix Published UI updates with Bindings on alerts
macteuts Dec 5, 2023
99be02d
:recycle: (AccountKit): Refactor AuthManager for better error handling
macteuts Dec 6, 2023
f246e60
:rotating_light: (AccountKit): Fix warnings in CompanyCredentialsView…
macteuts Dec 7, 2023
845e8b7
:bug: (AccountKit): Fix double verification alert on signUp
macteuts Dec 7, 2023
bb506ea
:recycle: (AccountKit): Remove commented code and add logs using LogKit
macteuts Dec 8, 2023
d44ab68
:wrench: (AccountKit): Add OTHER_FLAGS: -ObjC
ladislas Dec 8, 2023
874720f
:bug: (AccountKit): Add ObjC flag to project.swift
macteuts Dec 10, 2023
0049ffb
:art: (AccountKit): Run swiftformat on all files
macteuts Dec 10, 2023
e538c2b
:loud_sound: (AccountKit): Replace print w/ logs in AuthManager
macteuts Dec 10, 2023
cc2ce71
:sparkles: (AccountKit): Make AuthManager publicly available
macteuts Dec 10, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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>API_KEY</key>
<string>AIzaSyD_cqCvLrJYzfPOyZCOFAsBdfK-72MJE_A</string>
<key>GCM_SENDER_ID</key>
<string>749287588285</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.leka.apf.app.example.AccountKitExample</string>
<key>PROJECT_ID</key>
<string>leka-app-dev</string>
<key>STORAGE_BUCKET</key>
<string>leka-app-dev.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:749287588285:ios:a01a2fe13de24e96ff92d4</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import FirebaseCore
import LogKit
import SwiftUI

// MARK: - AppDelegate

class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
FirebaseApp.configure()
return true
}
}

let log = LogKit.createLoggerFor(app: "AccountKitExample")

// MARK: - AccountKitExample

@main
struct AccountKitExample: App {
@StateObject var authenticationState = OrganisationAuthState()
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject var authManager = AuthManager()

var body: some Scene {
WindowGroup {
MainView()
.environmentObject(self.authenticationState)
.environmentObject(self.authManager)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import SwiftUI

struct MainView: View {
// MARK: Internal

@EnvironmentObject var authenticationState: OrganisationAuthState
@EnvironmentObject var authManager: AuthManager

var body: some View {
Group {
switch self.authenticationState.organisationIsAuthenticated {
switch self.authManager.companyAuthenticationState {
case .unknown:
Text("Loading...")
case .loggedIn:
Expand All @@ -23,13 +24,9 @@ struct MainView: View {
}
}
.animation(
.easeOut(duration: 0.4),
value: self.authenticationState.organisationIsAuthenticated
.easeOut(duration: 0.4), value: self.authManager.companyAuthenticationState
)
.preferredColorScheme(.light)
.onAppear(perform: {
self.authenticationState.organisationIsAuthenticated = .loggedOut
})
}

// MARK: Private
Expand All @@ -55,11 +52,16 @@ struct MainView: View {
.controlSize(.large)
.navigationTitle("Authentication")
.navigationBarBackButtonHidden()
.alert("An error occurred", isPresented: self.$authManager.showErrorAlert) {
// nothing to show
} message: {
Text(self.authManager.errorMessage)
}
}
}
}

#Preview {
MainView()
.environmentObject(OrganisationAuthState())
.environmentObject(AuthManager())
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import SwiftUI

struct ForgotPasswordView: View {
@State private var organisation = OrganisationViewModel()
@EnvironmentObject var authManager: AuthManager
@State private var credentials = CompanyCredentialsViewModel.shared
@State private var showErrorAlert = false
@Environment(\.dismiss) var dismiss

var body: some View {
Expand All @@ -20,20 +23,33 @@ struct ForgotPasswordView: View {
.navigationTitle("Reset Password View")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.animation(.default, value: self.organisation.isEmailValid())
.animation(.default, value: self.credentials.isEmailValid())
.navigationBarItems(trailing: Button("Dismiss", action: { self.dismiss() }))
.alert("Réinitialiser le mot de passe", isPresented: self.$authManager.showNotificationAlert) {
// nothing to show
} message: {
Text(self.authManager.notificationMessage)
}
.alert("An error occurred", isPresented: self.$showErrorAlert) {
// nothing to show
} message: {
Text(self.authManager.errorMessage)
}
.onReceive(self.authManager.$showErrorAlert) { newValue in
self.showErrorAlert = newValue
}
}
}

private var emailField: some View {
VStack(alignment: .leading, spacing: 10) {
TextField("email", text: self.$organisation.mail)
TextField("email", text: self.$credentials.mail)
.textFieldStyle(.roundedBorder)
.keyboardType(.emailAddress)
if !self.organisation.mail.isEmpty,
!self.organisation.isEmailValid()
if !self.credentials.mail.isEmpty,
!self.credentials.isEmailValid()
{
Text(self.organisation.invalidEmailAddressText)
Text(self.credentials.invalidEmailAddressText)
.font(.footnote)
.foregroundStyle(.red)
.padding(.horizontal, 10)
Expand All @@ -44,18 +60,22 @@ struct ForgotPasswordView: View {
private var resetPasswordButton: some View {
Button(
action: {
self.dismiss()
self.authManager.sendPasswordReset(to: self.credentials.mail)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
self.dismiss()
}
},
label: {
Text("Reset Password")
.frame(maxWidth: .infinity)
}
)
.buttonStyle(.borderedProminent)
.disabled(!self.organisation.isEmailValid())
.disabled(!self.credentials.isEmailValid())
}
}

#Preview {
ForgotPasswordView()
.environmentObject(AuthManager())
}
Loading
Loading