23 lines
742 B
C#
23 lines
742 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using bts.api;
|
|
using bts.api.core;
|
|
|
|
namespace bts.api
|
|
{
|
|
public class Authenticator
|
|
{
|
|
readonly static Lazy<user.UserService> _auth = new Lazy<user.UserService>(() => Locator.locate<user.UserService>(), true);
|
|
user.AuthToken _token = null;
|
|
public Authenticator() { }
|
|
|
|
public user.AuthToken last_token => _token;
|
|
public async Task<user.AuthToken> login(string login, string password)
|
|
{
|
|
var res = await _auth.Value.authenticate_login_async(new user.AuthenticateLoginRequest { Login = login, Password = password });
|
|
if (res.success)
|
|
_token = res.value.Token;
|
|
return _token;
|
|
}
|
|
}
|
|
} |