narsil/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs

38 lines
1.0 KiB
C#
Raw Normal View History

using Tanshu.Accounts.Repository;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.PointOfSale
{
class MsrLogin : ILogin
{
//private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public bool LoginUser()
{
return LoginUser(true);
}
static bool LoginUser(bool setThreadPrincipal)
{
using (var frm = new MsrLoginForm(false))
{
string userName;
frm.ShowDialog();
var authenticated = frm.UserName(out userName);
if (authenticated && setThreadPrincipal)
using (var bi = new UserBI())
{
Session.User = bi.Get(x => x.Name == userName);
}
return authenticated;
}
}
public bool LogoutUser()
{
Session.User = null;
return true;
}
}
}