Giter VIP home page Giter VIP logo

authlogin's Introduction

AuthLogin

express登录控制案例

主要利用mongooseexpress-sessionbody-parser模块。

首先利用express-generator生成一个express项目。把默认生成的index.ejs页面作为访问控制页面,新增登录页面login.ejs、注册页面register.ejs,相应的路由控制文件和用户模型models/user.js

所有的控制围绕req.session展开,访问index.ejs页面在req.session.user不存在时,重定向到登录页面;登录时,获取post请求的相关参数,在数据库查询相应的数据,并做出对应的响应;注册同理,查询数据库是否存在所注册的账号,并作出相应的响应;登出及清空所有session。

authlogin's People

Contributors

joydezhong avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.