Skip to content
Merged
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
17 changes: 17 additions & 0 deletions SportApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3153F0FA2E211AF60032B87D /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 3153F0F92E211AF60032B87D /* KeychainAccess */; };
319C0F1D2E1EAC3900BF7D83 /* JWTDecode in Frameworks */ = {isa = PBXBuildFile; productRef = 319C0F1C2E1EAC3900BF7D83 /* JWTDecode */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -74,6 +75,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3153F0FA2E211AF60032B87D /* KeychainAccess in Frameworks */,
319C0F1D2E1EAC3900BF7D83 /* JWTDecode in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -139,6 +141,7 @@
name = SportApp;
packageProductDependencies = (
319C0F1C2E1EAC3900BF7D83 /* JWTDecode */,
3153F0F92E211AF60032B87D /* KeychainAccess */,
);
productName = SportApp;
productReference = 310422A42E14371C00D64B73 /* SportApp.app */;
Expand Down Expand Up @@ -224,6 +227,7 @@
minimizedProjectReferenceProxies = 1;
packageReferences = (
319C0F1B2E1EAC3900BF7D83 /* XCRemoteSwiftPackageReference "JWTDecode" */,
3153F0F82E211A820032B87D /* XCRemoteSwiftPackageReference "KeychainAccess" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 310422A52E14371C00D64B73 /* Products */;
Expand Down Expand Up @@ -631,6 +635,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
3153F0F82E211A820032B87D /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess.git";
requirement = {
branch = master;
kind = branch;
};
};
319C0F1B2E1EAC3900BF7D83 /* XCRemoteSwiftPackageReference "JWTDecode" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/auth0/JWTDecode.swift";
Expand All @@ -642,6 +654,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
3153F0F92E211AF60032B87D /* KeychainAccess */ = {
isa = XCSwiftPackageProductDependency;
package = 3153F0F82E211A820032B87D /* XCRemoteSwiftPackageReference "KeychainAccess" */;
productName = KeychainAccess;
};
319C0F1C2E1EAC3900BF7D83 /* JWTDecode */ = {
isa = XCSwiftPackageProductDependency;
package = 319C0F1B2E1EAC3900BF7D83 /* XCRemoteSwiftPackageReference "JWTDecode" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SportApp/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct HomeView: View {
.interactiveDismissDisabled(true)
}
// .onAppear() {
// if let token = UserDefaults.standard.string(forKey: "auth_token") {
// if let token = KeyСhainManager.shared.getToken() {
// print(token + " aaaaaaaaaaaaaa")
// if viewModelOfRegistration.getTokenExpiration(token) ?? Date() > Date() {
// isAuthenticated = true
Expand Down
1 change: 1 addition & 0 deletions SportApp/NetworkService/Data/APIRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
struct APIRoutes {
let baseURL = URL(string: "http://51.250.38.151:8082")
let userURL = URL(string: "http://51.250.38.151:8081")
let bffURL = URL(string: "http://51.250.38.151:8083")
let getTournirs: String = "/api/v1/tournaments"
let login: String = "/api/v1/auth/login"
let register: String = "/api/v1/auth/register"
Expand Down
9 changes: 7 additions & 2 deletions SportApp/Profile/View/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,13 @@ struct ProfileView: View {
}
}
}
.onAppear {
.onAppear() {
loadUserData()
}
// .onChange(of: viewModelOfRegistration.user) {
// loadUserData()
// print($0)
// }
}

// Загружаем данные пользователя в @State переменные
Expand Down Expand Up @@ -362,7 +366,8 @@ struct ProfileView: View {

// Выход
func logout() {
UserDefaults.standard.removeObject(forKey: "auth_token")
//UserDefaults.standard.removeObject(forKey: "auth_token")
KeyСhainManager.shared.deleteToken()
isActive = false
viewModelOfRegistration.token = nil
viewModelOfRegistration.user = nil
Expand Down
2 changes: 2 additions & 0 deletions SportApp/Registration/View/RegistrationShieldView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ struct RegistrationShieldView: View {
}

func dismiss(user: User) {
var user = user
user.isAdmin = coordinator.user.isAdmin
coordinator.user = user//User(phio: phio, password: password, email: email, isAdmin: coordinator.user.isAdmin)
coordinator.dismissSheet()
isAuthenticated = true
Expand Down
38 changes: 38 additions & 0 deletions SportApp/Registration/ViewModel/KeyChainManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// KeyChainManager.swift
// SportApp
//
// Created by Zaitsev Vladislav on 11.07.2025.
//

import KeychainAccess

class KeyСhainManager {
static let shared = KeyСhainManager()

private let keychain: Keychain

private init() {
self.keychain = Keychain(service: "com.yourapp.sportapp")
}

func saveToken(_ number: String) {
do {
try keychain.set(number, key: "token")
} catch {
print(error)
}
}

func getToken() -> String? {
return keychain["token"]
}

func deleteToken() {
do {
try keychain.remove("token")
} catch {
print("error")
}
}
}
3 changes: 2 additions & 1 deletion SportApp/Registration/ViewModel/RegistrationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class RegistrationViewModel: ObservableObject {
self.token = newToken
//print(self.token ?? "nil")
NetworkService.shared.token = token
UserDefaults.standard.set(newToken, forKey: "auth_token")
KeyСhainManager.shared.saveToken(newToken)
//UserDefaults.standard.set(newToken, forKey: "auth_token")
//JWTDecodeFunc(jwt: newToken)
//print(getTokenExpiration(newToken))
//print(getTokenID(newToken) ?? "aaa")
Expand Down
2 changes: 2 additions & 0 deletions SportApp/Tournirs/View/TournirRegistration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,7 @@ struct TournirRegistration: View {
if bio != "" {
coordinator.user.bio = bio
}

coordinator.updateUser()
}
}
Loading