optimizes login method
This commit is contained in:
parent
32a071b6c7
commit
a05e149b31
@ -22,21 +22,22 @@ public class PiwigoContext : IPiwigoContext
|
|||||||
|
|
||||||
public async Task LoginAsync()
|
public async Task LoginAsync()
|
||||||
{
|
{
|
||||||
|
if (IsLoggedIn)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("The client is already logged in!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var userName = _config.UserName;
|
var userName = _config.UserName;
|
||||||
if (string.IsNullOrWhiteSpace(userName))
|
if (string.IsNullOrWhiteSpace(userName))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Value cannot be null or whitespace.", nameof(userName));
|
throw new PiwigoException("username cannot be null or whitespace.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var password = _config.Password;
|
var password = _config.Password;
|
||||||
if (string.IsNullOrWhiteSpace(password))
|
if (string.IsNullOrWhiteSpace(password))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Value cannot be null or whitespace.", nameof(password));
|
throw new PiwigoException("password cannot be null or whitespace.");
|
||||||
}
|
|
||||||
|
|
||||||
if (IsLoggedIn)
|
|
||||||
{
|
|
||||||
throw new PiwigoException("The client is already logged in. Create a new instance or log out first!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Logging into {PiwigoBaseUri} using username {Username}", _config.BaseUri, userName);
|
_logger.LogInformation("Logging into {PiwigoBaseUri} using username {Username}", _config.BaseUri, userName);
|
||||||
|
Loading…
Reference in New Issue
Block a user