Vapor Documentation

Structure Request.​Authentication

public struct Authentication  

Request helper for storing and fetching authenticated objects.

Member Of

Request

Represents an HTTP request in an application.

Methods

login(_:​)

public func login<A>(_ instance: A)
        where A: Authenticatable

Authenticates the supplied instance for this request.

logout(_:​)

public func logout<A>(_ type: A.Type = A.self)
        where A: Authenticatable

Unauthenticates an authenticatable type.

require(_:​)

@discardableResult public func require<A>(_ type: A.Type = A.self) throws -> A
        where A: Authenticatable

Returns an instance of the supplied type. Throws if no instance of that type has been authenticated or if there was a problem.

get(_:​)

public func get<A>(_ type: A.Type = A.self) -> A?
        where A: Authenticatable

Returns the authenticated instance of the supplied type.

has(_:​)

public func has<A>(_ type: A.Type = A.self) -> Bool
        where A: Authenticatable

Returns true if the type has been authenticated.