N
N
narem2019-10-08 11:22:33
Node.js
narem, 2019-10-08 11:22:33

Where can I get an example of the simplest node authorization?

I'm trying to figure out authorization, but the problem is that in order to understand, I need to visually see how it works at the most primitive level.
I understand that you need to take the data entered by the user, then compare it with the data from the database, but what's next?

const express = require('express'),
  app = express(),
  port = 3000
  datas = ['ad','1234'];
  
app.set("view engine", "ejs");

app.get('/',(request,response) => {
  response.render('login');
  let auth = [request.query.login,request.query.passwor];
  if(datas[0] == auth[0] && datas[1] == auth[1]){
    console.log('Верный логин и пароль');
  }else{
    console.log('Неверный логин или пароль');
  }
});

app.get('/1',(request,response) => {
  response.render('1');
});

app.get('/2',(request,response) => {
  response.render('1');
});
  
app.listen(port,(err) => {
  if(err){
    return console.log(err);
  }
  
  console.log(`Слушается порт ${port}`);
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question