Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion server_app/user/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const modelService = require("../model/service");
const login = async ({ username, password }) => {
return new Promise(async (resolve, reject) => {
try {
username = username.toLowerCase();
const userDocument = await UserRepository.findOne({
"login": username,
"password": encriptor.Crypto(password, username),
Expand All @@ -29,6 +30,7 @@ const login = async ({ username, password }) => {
const create = async ({ username, password, mail }) => {
return new Promise(async (resolve, reject) => {
try {
mail = mail.toLowerCase();
const user = await UserRepository.findOne({ "login": mail });

if (user != null) {
Expand All @@ -52,6 +54,7 @@ const create = async ({ username, password, mail }) => {
const recovery = async (email) => {
return new Promise(async (resolve, reject) => {
try {
email = email.toLowerCase();
const user = await UserRepository.findOne({ "login": email });

if (user == null) {
Expand Down Expand Up @@ -89,6 +92,7 @@ const recovery = async (email) => {

const isValidRecovery = async (mail, code) => {
try {
mail = mail.toLowerCase();
const user = await UserRepository.findOne({ "login": mail, "recoveryCode": code });

if (user == null) {
Expand All @@ -105,7 +109,7 @@ const isValidRecovery = async (mail, code) => {
const resetPassword = async (mail, code, newPassword) => {
return new Promise(async (resolve, reject) => {
try {

mail = mail.toLowerCase();
const isValid = await isValidRecovery(mail, code)
if (!isValid) {
return reject(new Error("Invalid recovery code"));
Expand Down