2021-06-09 01:53:30 +03:00
|
|
|
import * as Data from "~/node_common/data";
|
|
|
|
import * as Validations from "~/common/validations";
|
|
|
|
import * as Strings from "~/common/strings";
|
|
|
|
import * as Environment from "~/node_common/environment";
|
2021-06-11 22:25:58 +03:00
|
|
|
import * as Logging from "~/common/logging";
|
2021-06-09 01:53:30 +03:00
|
|
|
|
|
|
|
export default async (req, res) => {
|
|
|
|
const username = req.body.data.username.toLowerCase();
|
|
|
|
let user;
|
|
|
|
if (Validations.email(username)) {
|
|
|
|
try {
|
|
|
|
user = await Data.getUserByEmail({ email: username });
|
|
|
|
} catch (e) {
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.error(e);
|
2021-06-09 01:53:30 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
user = await Data.getUserByUsername({
|
|
|
|
username: req.body.data.username.toLowerCase(),
|
|
|
|
});
|
|
|
|
} catch (e) {
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.error(e);
|
2021-06-09 01:53:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
return res.status(200).send({ decorator: "SERVER_USER_NOT_FOUND" });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (user.error) {
|
|
|
|
return res.status(500).send({ decorator: "SERVER_USER_NOT_FOUND", error: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
return res
|
|
|
|
.status(200)
|
|
|
|
.send({ decorator: "SERVER_GET_USER_VERSION", data: { version: user.authVersion } });
|
|
|
|
};
|