Table of Contents

Class UserCode

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.Core.dll

The one form of a user code that this server stores and compares.

public static class UserCode
Inheritance
UserCode
Inherited Members

Remarks

A user code is read off one screen and typed into another, so it arrives in whatever case and spacing the person used. Leaving that to the store would answer the same typing three different ways: the in-memory store compares ordinal, SQLite compares by binary collation, and SQL Server's default collation is case-insensitive — so whether a code worked would depend on which store a host configured, which is the worst way for it to fail. So it is canonicalised where it enters the server instead, and every store sees only this form.

Only case and the separators a person adds are removed. Anything else is part of the code: a replaced IUserCodeService chooses its own alphabet, and this must not decide which of its characters count.

Methods

Canonical(string?)

The user code in the one form this server stores and compares: upper case, with whitespace and hyphens removed.

public static string Canonical(string? userCode)

Parameters

userCode string

The code as issued or as typed.

Returns

string

The canonical form, or an empty string when userCode is null or empty.