Skip to content

Commit

Permalink
[mirotalkwebrtc] - improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Oct 5, 2024
1 parent 139cbc9 commit 092ff1c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions backend/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ components:
email:
type: string
example: '[email protected]'
username:
type: string
example: 'Miroslav Pejic'
password:
type: string
example: 'Test@123'
Expand Down
19 changes: 15 additions & 4 deletions backend/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ async function userLogin(req, res) {
const payload = { username: username, email: email, password: password };
const token = utils.tokenEncode(payload);

const userFindOne = await User.findOne({ email: email });
//const userFindOne = await User.findOne({ email: email });
const userFindOne = await User.findOne({
$or: [
{ email: email },
{ username: username }
]
});

if (!Object.is(userFindOne, null) && userFindOne.active) {
log.debug('User found, but we going to check if the provided password exists');
Expand Down Expand Up @@ -187,10 +193,15 @@ async function userIsAuth(req, res) {
try {
log.debug('userIsAuth query', req.body);

const { email, password } = req.body;
const { email, username, password } = req.body;

// Check by email as uuid and indexed
const userFindOne = await User.findOne({ email: email });
// Check by email (uuid) or username as indexed
const userFindOne = await User.findOne({
$or: [
{ email: email },
{ username: username ? username : email }
]
});

if (Object.is(userFindOne, null) || !userFindOne.active) {
log.debug('user not found!', email);
Expand Down
2 changes: 1 addition & 1 deletion backend/models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const userSchema = new mongoose.Schema({
role: { type: String, default: 'guest' },
allow: { type: Array, default: ['ALL'] },
email: { type: String, index: { unique: true } },
username: { type: String },
username: { type: String, index: { unique: false } },
password: { type: String },
token: { type: String },
active: { type: Boolean, enum: [true, false], default: false },
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: [email protected] or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/a-selfhosted-mirotalks-webrtc-rooms-scheduler-server/42643313
* @author Miroslav Pejic - [email protected]
* @version 1.0.93
* @version 1,0,94
*/

const isMobile = !!/Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalkwebrtc",
"version": "1.0.93",
"version": "1,0,94",
"description": "MiroTalk WebRTC admin",
"main": "server.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"license": "AGPL-3.0",
"homepage": "https://github.com/miroslavpejic85/mirotalkwebrtc",
"dependencies": {
"@sentry/node": "^8.31.0",
"@sentry/node": "^8.33.1",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
"colors": "1.4.0",
Expand All @@ -44,11 +44,11 @@
"express": "^4.21.0",
"jsonwebtoken": "^9.0.2",
"js-yaml": "^4.1.0",
"mongoose": "^8.6.3",
"mongoose": "^8.7.0",
"ngrok": "^5.0.0-beta.2",
"nodemailer": "^6.9.15",
"swagger-ui-express": "^5.0.1",
"twilio": "^5.3.1"
"twilio": "^5.3.3"
},
"devDependencies": {
"nodemon": "^3.1.7",
Expand Down

0 comments on commit 092ff1c

Please sign in to comment.