llaske / sugarizer-server

Sugarizer Server allow deployment of Sugarizer on a local server, for example on a school server.
Apache License 2.0
43 stars 94 forks source link

teacher not able to log in #375

Closed parteekcoder closed 1 year ago

parteekcoder commented 1 year ago

Reproduce

  1. try to login using teacher account
  2. You will see this error

Screenshot_20230301_182234 Screenshot_20230301_182248

parteekcoder commented 1 year ago

@llaske this error persist due to these lines

    query['_id'] = {
            $in: req.user.classrooms.map(function(id) {
                return new mongo.ObjectID(id);
            })
        };

query['_id'] = {
            $in: req.user.students.map(function(id) {
                return new mongo.ObjectID(id);
            })
        };

and etc.

llaske commented 1 year ago

Sorry it's impossible to reproduce your issue. It's probably because you're environment is incorrect or patched by your hand. We can't help you without a clear path to reproduce the issue from a standard environment.

parteekcoder commented 1 year ago

I just simple cloned the repo then installed the dependencies and ran the server this my teacher object in database

image

Can you please once explain how req.user.students is defined as we are not passing it from the frontend

Can you please explain the steps you followed

NikhilM98 commented 1 year ago

A teacher should be created with valid classrooms. If you create a teacher with Sugarizer Server dashboard, then it is created with classroom. Did you create this object manually?

parteekcoder commented 1 year ago

yes

NikhilM98 commented 1 year ago

That explains why your object has some keys missing. It's better to create these objects from the dashboard.