Skip to content

Commit 8370b23

Browse files
committed
Add Auth Way with disable anon auth. Fixed toolbar.
1 parent 8d73d5b commit 8370b23

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
dependencies: [
1818
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.2.0")),
1919
.package(url: "https://github.com/ivanvorobei/NativeUIKit", .upToNextMajor(from: "1.4.1")),
20-
.package(url: "https://github.com/ivanvorobei/SPFirebase", .upToNextMajor(from: "1.0.6")),
20+
.package(url: "https://github.com/ivanvorobei/SPFirebase", .upToNextMajor(from: "1.0.7")),
2121
.package(url: "https://github.com/sparrowcode/SPSafeSymbols", .upToNextMajor(from: "1.0.5")),
2222
.package(url: "https://github.com/kean/Nuke", .upToNextMajor(from: "10.7.1"))
2323
],

Sources/SPProfiling/Interface/Auth/AuthController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,17 @@ open class AuthController: NativeOnboardingFeaturesController {
102102

103103
@objc func updateSkipAuthButton() {
104104
let allowed: Bool = {
105-
if ProfileModel.isAnonymous != nil {
106-
// Any auth already isset.
107-
// Not allowed anonymous auth.
105+
switch SPProfiling.authWay {
106+
case .onlyAuthed:
108107
return false
109-
} else {
110-
return true
108+
case .anonymouslyAllowed:
109+
if ProfileModel.isAnonymous != nil {
110+
// Any auth already isset.
111+
// Not allowed anonymous auth.
112+
return false
113+
} else {
114+
return true
115+
}
111116
}
112117
}()
113118
actionToolbarView.skipAuthButton.isHidden = !allowed

Sources/SPProfiling/Interface/Auth/AuthToolBarView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ open class AuthToolBarView: NativeMimicrateToolBarView {
5555
open func setLoading(_ state: Bool) {
5656
if state {
5757
activityIndicatorView.startAnimating()
58-
authButton.isHidden = true
59-
skipAuthButton.isHidden = true
58+
authButton.alpha = .zero
59+
skipAuthButton.alpha = .zero
6060
} else {
6161
activityIndicatorView.stopAnimating()
62-
authButton.isHidden = false
63-
skipAuthButton.isHidden = false
62+
authButton.alpha = 1
63+
skipAuthButton.alpha = 1
6464
}
6565
}
6666

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
3+
public enum AuthWay {
4+
5+
case onlyAuthed
6+
case anonymouslyAllowed
7+
}

Sources/SPProfiling/SPProfiling.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import SPFirebaseAuth
2727

2828
public class SPProfiling {
2929

30-
public static func configure(firebaseOptions: FirebaseOptions) {
30+
public static func configure(_ authWay: AuthWay, firebaseOptions: FirebaseOptions) {
31+
32+
shared.authWay = authWay
3133

3234
// Start Firebase
3335
SPFirebase.configure(with: firebaseOptions)
@@ -89,13 +91,7 @@ public class SPProfiling {
8991

9092
static func signOut(completion: @escaping (AuthError?)->Void) {
9193
Auth.signOut { error in
92-
if let error = error {
93-
completion(error)
94-
} else {
95-
signInAnonymously() { error in
96-
completion(error)
97-
}
98-
}
94+
completion(error)
9995
}
10096
}
10197

@@ -147,6 +143,7 @@ public class SPProfiling {
147143

148144
// MARK: - Singltone
149145

146+
private var authWay: AuthWay = .anonymouslyAllowed
150147
private var authProcess: Bool = false
151148
private static let shared = SPProfiling()
152149
private init() {}
@@ -157,4 +154,6 @@ public class SPProfiling {
157154
get { SPProfiling.shared.authProcess }
158155
set { SPProfiling.shared.authProcess = newValue }
159156
}
157+
158+
public static var authWay: AuthWay { shared.authWay }
160159
}

Sources/SPProfiling/Services/Auth.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ class Auth {
7373
if let error = error {
7474
completion(AuthError.convert(error))
7575
} else {
76-
signInAnonymously() { error in
77-
completion(error)
78-
}
76+
completion(nil)
7977
}
8078
})
8179
}

0 commit comments

Comments
 (0)