mirror of
https://github.com/microsoft/TypeScript-Node-Starter.git
synced 2025-11-09 00:37:27 +00:00
Merge branch 'master' into refactor-remove-unused-imports
This commit is contained in:
@@ -2,7 +2,7 @@ import async from "async";
|
||||
import crypto from "crypto";
|
||||
import nodemailer from "nodemailer";
|
||||
import passport from "passport";
|
||||
import { default as User, UserModel, AuthToken } from "../models/User";
|
||||
import { User, UserDocument, AuthToken } from "../models/User";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { IVerifyOptions } from "passport-local";
|
||||
import { WriteError } from "mongodb";
|
||||
@@ -37,7 +37,7 @@ export let postLogin = (req: Request, res: Response, next: NextFunction) => {
|
||||
return res.redirect("/login");
|
||||
}
|
||||
|
||||
passport.authenticate("local", (err: Error, user: UserModel, info: IVerifyOptions) => {
|
||||
passport.authenticate("local", (err: Error, user: UserDocument, info: IVerifyOptions) => {
|
||||
if (err) { return next(err); }
|
||||
if (!user) {
|
||||
req.flash("errors", info.message);
|
||||
@@ -138,7 +138,7 @@ export let postUpdateProfile = (req: Request, res: Response, next: NextFunction)
|
||||
return res.redirect("/account");
|
||||
}
|
||||
|
||||
User.findById(req.user.id, (err, user: UserModel) => {
|
||||
User.findById(req.user.id, (err, user: UserDocument) => {
|
||||
if (err) { return next(err); }
|
||||
user.email = req.body.email || "";
|
||||
user.profile.name = req.body.name || "";
|
||||
@@ -174,7 +174,7 @@ export let postUpdatePassword = (req: Request, res: Response, next: NextFunction
|
||||
return res.redirect("/account");
|
||||
}
|
||||
|
||||
User.findById(req.user.id, (err, user: UserModel) => {
|
||||
User.findById(req.user.id, (err, user: UserDocument) => {
|
||||
if (err) { return next(err); }
|
||||
user.password = req.body.password;
|
||||
user.save((err: WriteError) => {
|
||||
@@ -276,7 +276,7 @@ export let postReset = (req: Request, res: Response, next: NextFunction) => {
|
||||
});
|
||||
});
|
||||
},
|
||||
function sendResetPasswordEmail(user: UserModel, done: Function) {
|
||||
function sendResetPasswordEmail(user: UserDocument, done: Function) {
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: "SendGrid",
|
||||
auth: {
|
||||
@@ -350,7 +350,7 @@ export let postForgot = (req: Request, res: Response, next: NextFunction) => {
|
||||
});
|
||||
});
|
||||
},
|
||||
function sendForgotPasswordEmail(token: AuthToken, user: UserModel, done: Function) {
|
||||
function sendForgotPasswordEmail(token: AuthToken, user: UserDocument, done: Function) {
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: "SendGrid",
|
||||
auth: {
|
||||
|
||||
Reference in New Issue
Block a user