Commit 7c83f8b0 authored by Pavel Mishakov's avatar Pavel Mishakov

some fixes

parent cd4ef015
......@@ -48,10 +48,8 @@ export class UserController {
}
public checkToken = async (req: Request, res: Response): Promise<void> => {
const user = await User.findOne({token: req.get('Authorization')})
console.log(user)
if(!user) {
res.status(200).send({
status: EStatuses.OK,
......
......@@ -12,7 +12,6 @@ import { UserController } from './controllers/user'
import { mongo } from './repository/mongo'
dotenv.config()
class App {
private app: Express
constructor() {
......
......@@ -244,9 +244,18 @@ export class Mongo implements IDataBase {
public createUser = async (userDto: IUserDto): Promise<IResponse<IUser | undefined>> => {
try {
const exists = await User.exists({username: userDto.username})
if (exists) {
return {
status: EStatuses.NOT_OK,
result: undefined,
message: '[ERROR] User already registered'
}
}
const user = new User(userDto)
// @ts-ignore
user.generateToken()
// user.token = '1234'
const data = await user.save()
return {
status: EStatuses.OK,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment