Search Results for

    Show / Hide Table of Contents

    Class TokenService

    Service for managing registration tokens

    Inheritance
    object
    TokenService
    Implements
    ITokenService
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: OEMS.Core.Application.ApplicationServices
    Assembly: OEMS.Core.dll
    Syntax
    public class TokenService : ITokenService

    Constructors

    TokenService(IUserRegistrationTokenRepository, IUserRepository, ILogger<TokenService>)

    Initializes a new instance of the TokenService class

    Declaration
    public TokenService(IUserRegistrationTokenRepository tokenRepository, IUserRepository userRepository, ILogger<TokenService> logger)
    Parameters
    Type Name Description
    IUserRegistrationTokenRepository tokenRepository

    Repository for token operations

    IUserRepository userRepository

    Repository for user operations

    ILogger<TokenService> logger

    Logger for the token service

    Methods

    CleanupExpiredTokensAsync()

    Cleans up expired tokens from the database

    Declaration
    public Task<int> CleanupExpiredTokensAsync()
    Returns
    Type Description
    Task<int>

    The number of tokens cleaned up

    GenerateTokenAsync(Guid, Guid, TokenType, int)

    Generates a secure token for user registration

    Declaration
    public Task<string> GenerateTokenAsync(Guid userId, Guid organizationId, TokenType tokenType, int expiryDays = 7)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user the token is for

    Guid organizationId

    The ID of the organization the token is for

    TokenType tokenType

    The type of token to generate

    int expiryDays

    Number of days until the token expires (default: 7)

    Returns
    Type Description
    Task<string>

    The generated token string

    InvalidateTokenAsync(string)

    Invalidates a specific token

    Declaration
    public Task<bool> InvalidateTokenAsync(string token)
    Parameters
    Type Name Description
    string token

    The token string to invalidate

    Returns
    Type Description
    Task<bool>

    True if successful, false otherwise

    InvalidateUserTokensAsync(Guid)

    Invalidates all tokens for a user

    Declaration
    public Task<bool> InvalidateUserTokensAsync(Guid userId)
    Parameters
    Type Name Description
    Guid userId

    The user ID to invalidate tokens for

    Returns
    Type Description
    Task<bool>

    True if successful, false otherwise

    MarkTokenAsUsedAsync(string)

    Marks a token as used

    Declaration
    public Task<bool> MarkTokenAsUsedAsync(string token)
    Parameters
    Type Name Description
    string token

    The token string to mark as used

    Returns
    Type Description
    Task<bool>

    True if successful, false otherwise

    ValidateTokenAsync(string)

    Validates a registration token

    Declaration
    public Task<(bool isValid, Guid userId, Guid organizationId, string email)> ValidateTokenAsync(string token)
    Parameters
    Type Name Description
    string token

    The token to validate

    Returns
    Type Description
    Task<(bool isValid, Guid userId, Guid organizationId, string email)>

    Tuple containing: (isValid, userId, organizationId, email)

    Implements

    ITokenService
    In this article
    Back to top Generated by DocFX