私はnodejsを初めて使用しています。ビジュアルスタジオのMVCフレームワークでは、ロールを作成したり、ユーザー名に基づいてページの特定の部分やメッセージを表示することもできます。 nodejsでこれをどうやって行うことができますか?たとえば、 "You like cats" for username abcd
または "You like dogs" for username efgh
または "You're not an animal person" for all other users
のように表示したいログインページがあります。nodejsのユーザー名に基づいたユーザーのユニークなメッセージ
私は役割がうまくいくことは知っていますが、ここでは役割の代わりに、私はユーザー名に基づいてこれをしたいと思います。これも可能ですか?
サーバー側ログインパーツ:あなたは(例えばhandlebarsなど)テンプレート言語を使用しての中に見ることができるHTMLページに
function loginUser() {
var username = document.getElementsByClassName("username");
var password = document.getElementsByClassName("password");
$.ajax({
url: url + "/login",
method: "post",
data: {
username: username[0].value,
password: password[0].value
}
}).success(function(response) {
window.location.assign("/home");
}).error(function(response) {
alert("Incorrect username or password!");
});
}
あなたが現在作業しているコードを投稿することができますか? –
あなたのリクエストを作成するには、Node.jsのユーザー管理のためにpassport.jsを使用することをお勧めします。 – RLaaa