34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace VECV_WebApi.Common
|
|
{
|
|
public class AuthService
|
|
{
|
|
string connectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
|
|
// private string connectionString = "YourConnectionStringHere";
|
|
|
|
public bool Authenticate(string username, string password)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(connectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = new SqlCommand("AuthenticateUser", conn))
|
|
{
|
|
cmd.CommandType = System.Data.CommandType.StoredProcedure;
|
|
cmd.Parameters.AddWithValue("@Username", username);
|
|
cmd.Parameters.AddWithValue("@Password", password);
|
|
|
|
var result = cmd.ExecuteScalar();
|
|
|
|
return result != null; // If UserID is returned, login is successful
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} |