Я изучаю разработку фронта и в настоящее время работаю над проектом с 5 другими коллегами. Я должен реализовать страницу входа в систему. Мы также должны реализовать страницу регистра и входа в систему. Вот как часть моего HTML и JS -кода для страницы входа выглядит так: < /p>
Login here
Username
Password
Lost your password?
Don't have an account?
(Javascript)
window.addEventListener("load",function (){
var username = document.getElementById("Username");
var password = document.getElementById("Password");
var submit=document.getElementById("submitButton");
var messageContainer=document.getElementById("Login");
var auth =new Auth();
submit.addEventListener("click",function ()
{
var username = document.getElementById("Username").value;
var password = document.getElementById("Password").value;
});
auth.Login();
auth.Login(username,password)
.then(function(response){
const token=response.accessToken;
auth.login(auth.Token);
auth.token=token;
document.cookie="accessToken="+token;
console.log(response.accessToken);
})
.catch(function(e) {
console.log(e) ;
loginContainer.innerHTML=e.status+ " You have to be registered in order to
login";
});
});
function Auth(){
}
Auth.prototype.Login=function(Username, Password){
var root = 'https://ancient-caverns-16784.herokuapp.com';
return $.post(root+"/auth/login",{
username: 'test',
password: 'test'
},
function(response) {
var xmlhttp = new XMLHttpRequest();
console.log(xmlhttp);
xmlhttp.open("post", "Login", true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 401 && xmlhttp.status == 200) {
loginResults();
}
};
console.log(response);
});
};
< /code>
Из того, что я понял, мне нужно только добавить имя пользователя и пароль в функцию Auth. Я получаю ошибку, которая говорит: Auth.login не является функцией. Я что -то упускаю? Я был бы признателен за любую предоставленную помощь. < /P>
Спасибо! < /P>
Подробнее здесь: https://stackoverflow.com/questions/495 ... javascript
Получение аутентификации пользователей и паролей с помощью JavaScript ⇐ Html
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Лучшие практики PHP для аутентификации пользователей и безопасности паролей. [закрыто]
Anonymous » » в форуме Php - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-