Skip to content

IAuthService

Namespace: SlottyMedia.Backend.Services.Interfaces

This interface provides functionalities to authenticate a user. In this context, the Principal refers to the currently logged-in user.

public interface IAuthService

Methods

SignIn(String, String)

This method is used to sign in the user.

Task<Session> SignIn(string email, string password)

Parameters

email String

password String

Returns

Task<Session>

SignOut()

This method is used to sign out the user.

Task SignOut()

Returns

Task

RestoreSessionAsync()

Should restore a session by reading in accessToken, refreshToken Cookie

Task<Session> RestoreSessionAsync()

Returns

Task<Session>
Returns a supabase session

SaveSessionAsync(Session)

Saves the accessToken, refreshToken in form of a cookie in the clients browser

Task SaveSessionAsync(Session session)

Parameters

session Session
Session on which the tokens are extracted

Returns

Task
Returns the sessions again

IsAuthenticated()

Checks if a session exists

bool IsAuthenticated()

Returns

Boolean

GetAuthPrincipalId()

Retrieves the authentication principal's user ID. Returns null if no authentication principal is present.

Nullable<Guid> GetAuthPrincipalId()

Returns

Nullable<Guid>
The principal's ID or null if none was present

SetSession(String, String)

Sets a session in form of a cookie on the client side by using wwwroot/js/cookies.js

Task<Session> SetSession(string accessToken, string refreshToken)

Parameters

accessToken String
AccessToken about to be set as cookie

refreshToken String
RefreshToken about to be set as cookie

Returns

Task<Session>
Returns the session which was set

RefreshSession(String, String)

Restores a session on server- and client-side and refreshes a accessToken if necessary

Task<Session> RefreshSession(string accessToken, string refreshToken)

Parameters

accessToken String
AccessToken for restoration

refreshToken String
RefreshToken for restoration

Returns

Task<Session>
Returns the new session

GetCurrentSession()

Gets the current session set by the client

Session GetCurrentSession()

Returns

Session
Returns the session

RestoreSessionOnInit()

This sets the session on initialization of the page.

Task<Session> RestoreSessionOnInit()

Returns

Task<Session>