User rights

multistore
Laurent 2 years ago
parent 22760cdcac
commit 35a0056f86
  1. 19
      PadelClub/Data/DataStore.swift
  2. 4
      PadelClub/Views/Subscription/Guard.swift
  3. 8
      PadelClub/Views/User/User.swift

@ -46,4 +46,23 @@ class DataStore: ObservableObject {
self.objectWillChange.send()
}
var globalRights: UserRight {
if let _ = Guard.main.currentPlan {
return .creation
}
if let user = self.user, user.club_id != nil {
if user.umpire_code != nil {
return .creation
} else {
return .edition
}
}
// TODO what are the rules when testing the app?
// scenario example: one cancelled tournament
return .none
}
}

@ -103,7 +103,7 @@ import LeStorage
return transaction
}
var currentPlan: StoreItem {
var currentPlan: StoreItem? {
#if DEBUG
return .monthly
@ -116,7 +116,7 @@ import LeStorage
let plan = StorePlan(rawValue: vf.productId) {
return plan
}
return .none
return nil
#endif
}

@ -8,11 +8,19 @@
import Foundation
import LeStorage
enum UserRight: Int, Codable {
case none = 0
case edition = 1
case creation = 2
}
class User: UserBase {
public var id: String = Store.randomId()
public var username: String
public var email: String?
var club_id: String?
var umpire_code: String?
init(username: String, email: String? = nil) {
self.username = username

Loading…
Cancel
Save