-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/XboxAuthNet.Game/OAuth/MicrosoftOAuthLoginHintValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using XboxAuthNet.Game.Authenticators; | ||
using XboxAuthNet.Game.SessionStorages; | ||
using XboxAuthNet.OAuth; | ||
|
||
namespace XboxAuthNet.Game.OAuth; | ||
|
||
public class MicrosoftOAuthLoginHintValidator : ISessionValidator | ||
{ | ||
private ISessionSource<string> _loginHintSource; | ||
private readonly bool _throwWhenInvalid = false; | ||
|
||
public MicrosoftOAuthLoginHintValidator(bool throwWhenInvalid, ISessionSource<string> loginHintSource) | ||
{ | ||
_throwWhenInvalid = throwWhenInvalid; | ||
_loginHintSource = loginHintSource; | ||
} | ||
|
||
public ValueTask<bool> Validate(AuthenticateContext context) | ||
{ | ||
var loginHint = _loginHintSource.Get(context.SessionStorage); | ||
var loginHintExists = !string.IsNullOrEmpty(loginHint); | ||
if (_throwWhenInvalid && !loginHintExists) | ||
throw new MicrosoftOAuthException("LoginHint was empty.", 0); | ||
return new ValueTask<bool>(loginHintExists); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters