new init api and start auth
This commit is contained in:
1 parent
7941a858fd
commit
a172f05269
26 files changed
+640
-102
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MySqlConnector;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using uWine.Core.Domain.Entities;
|
||||
using uWine.Core.Domain.Repositories;
|
||||
|
||||
namespace uWine.Core.Infrastructure.Repository
|
||||
{
|
||||
public class MariaDbAuthenticationRepository : MariaDbServerRepository, IAuthenticationRepository
|
||||
{
|
||||
public MariaDbAuthenticationRepository(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Valid(User user)
|
||||
{
|
||||
if (user == null || string.IsNullOrEmpty(user.Username) || string.IsNullOrEmpty(user.Password)) return false;
|
||||
using (var conn = Connection())
|
||||
{
|
||||
var cmd = new MySqlCommand("sp_check_login", conn);
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.AddWithValue("@Username", user.Username);
|
||||
cmd.Parameters.AddWithValue("@Password", user.Password);
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return reader.GetBoolean("valid");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user