私はログインアプリケーションに取り組んでおり、現在Angular JSの部分で作業しています。私がAngular JSの新人として、私はそれに固執しています。私はログインアプリケーション
public bool ValidateLogin(string email, string password)
{
try
{
ConnectionFactory conFac = new ConnectionFactory();
string query = "pro_loginuser";
SqlParameter[] parameter = new SqlParameter[2];
parameter[0] = new SqlParameter("email", SqlDbType.NVarChar);
parameter[0].Value = email;
parameter[1] = new SqlParameter("password", SqlDbType.NVarChar);
parameter[1].Value = password;
DataTable dt = conFac.executeSelectStoredProc(query, parameter);
if (dt != null)
{
var isSuccess = (from c in dt.AsEnumerable()
select c.Field<bool>("isSuccess")).FirstOrDefault();
return isSuccess;
}
else
{
return false;
}
}
catch (Exception)
{
throw;
}
}
public CallerEntry GetUserDetails(string email,string password)
{
CallerEntry callerentry = new CallerEntry();
try
{
ConnectionFactory conFac = new ConnectionFactory();
string query = "pro_loginuserdetails";
SqlParameter[] parameter = new SqlParameter[2];
parameter[0] = new SqlParameter("email", SqlDbType.NVarChar);
parameter[0].Value = email;
parameter[1] = new SqlParameter("password", SqlDbType.NVarChar);
parameter[1].Value = password;
DataTable dt = conFac.executeSelectStoredProc(query, parameter);
if (dt != null)
{
callerentry = (from c in dt.AsEnumerable()
select new CallerEntry
{
vid = c.Field<int>("id"),
fname=c.Field<string>("fname"),
lname = c.Field<string>("lname"),
branch = c.Field<int>("branch"),
role = c.Field<int>("role")
}).FirstOrDefault();
}
return callerentry;
}
catch (Exception)
{
throw;
}
}
}
Getusereコードは、ログイン後、ユーザの他の詳細を取得することでプロジェクトに私のSQLデータベースに接続するための接続コードをwrittedています。ウェブAPIコードは、今、私は私がウェブAPIから資格情報を取得し、ログイン成功または失敗を進めて次のステップに取り組むことができません
[HttpGet]
[Route("api/Project/ValidateLogin/{email}/{password}")]
//e.g http://localhost:52352/api/Project/ValidateLogin/[email protected]/TEST123
public bool ValidateLogin(string email, string password)
{
return bal.ValidateLogin(email, password);
}
が行われます。私は、ログイン後、次のページを入力する必要があります
角度コード:loginService.jsとして新しいJSファイル名を作成し、index.htmlをするか、メインページにloginService.jsファイルを含める
angular.module('myApp', [])
.controller('login', ['$scope',
function ($scope) {
$http.get('http://localhost:52352/api/Project/ValidateLogin/' + emailId)
$http.get('http://localhost:52352/api/Project/ValidateLogin/' + password)
function()
{
}
}
});
};
}
]);
一般的に、私は以下を使用してログインAPIを起動し、ルーティングをAngularで管理している場合は応答を使用して処理を進めます。 var data = new FormData(); data.append( 'user'、userID); data.append( 'pass'、password); $ http.post( 'ログイン'、データ、{ \t withCredentials:偽、 \t transformRequest:angular.identity、 \tヘッダ:{ \t \t 'Content-Typeの':未定義 \t} \t})。成功(機能(レスポンス){ /// を操作するための応答を使用} – CrazyMac