File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -886,12 +886,25 @@ public final class AuthClient: Sendable {
886
886
)
887
887
}
888
888
889
+ /// Returns the current session, if any.
890
+ ///
891
+ /// The session returned by this property may be expired. Use ``session`` for a session that is guaranteed to be valid.
892
+ public var currentSession : Session ? {
893
+ try ? configuration. localStorage. getSession ( ) ? . session
894
+ }
895
+
896
+ /// Returns the current user, if any.
897
+ ///
898
+ /// The user returned by this property may be outdated. Use ``user(jwt:)`` method to get an up-to-date user instance.
899
+ public var currentUser : User ? {
900
+ try ? configuration. localStorage. getSession ( ) ? . session. user
901
+ }
902
+
889
903
/// Gets the current user details if there is an existing session.
890
904
/// - Parameter jwt: Takes in an optional access token jwt. If no jwt is provided, user() will
891
905
/// attempt to get the jwt from the current session.
892
906
///
893
- /// Should be used only when you require the most current user data. For faster results,
894
- /// session.user is recommended.
907
+ /// Should be used only when you require the most current user data. For faster results, ``currentUser`` is recommended.
895
908
public func user( jwt: String ? = nil ) async throws -> User {
896
909
var request = HTTPRequest ( url: configuration. url. appendingPathComponent ( " user " ) , method: . get)
897
910
You can’t perform that action at this time.
0 commit comments