Giter VIP home page Giter VIP logo

Comments (3)

meefik avatar meefik commented on June 18, 2024

Получение профиля через OAuth происходит в строчке https://github.com/meefik/ITMOproctor/blob/master/routes/profile.js#L90

Проверьте настройки авторизации в конфигурационном файле https://github.com/meefik/ITMOproctor/blob/master/config-example.json#L33

Возможно, поменялся формат JSON возвращаемого профиля, тогда это нужно править тут https://github.com/meefik/ITMOproctor/blob/master/db/index.js#L47

from itmoproctor.

eazaika avatar eazaika commented on June 18, 2024

cookie

_ym_uid=***; 
_ga=***; 
openedx-language-preference=ru;
 _ym_d=***; 
_gid=***;
 _ym_isad=2; 
edxloggedin=true; 
_ym_visorc_47949185=w; 
authenticated=true; 
_gat_gtag_UA_114846701_1=1; 
csrftoken=***; 
edx-user-info="{\"username\": \"testuser\"}"; 
sessionid="***"

routes/profile.js

// OAuth2 strategy (LETIteach)
passport.use('LETIteach', new OAuth2Strategy({
    authorizationURL: config.get('auth:LETIteach:authorizationURL'),
    tokenURL: config.get('auth:LETIteach:tokenURL'),
    clientID: config.get('auth:LETIteach:clientID'),
    clientSecret: config.get('auth:LETIteach:clientSecret'),
    callbackURL: config.get('auth:LETIteach:callbackURL'),
    scope: config.get('auth:LETIteach:scope')
}, function(accessToken, refreshToken, prof, done) {
    var userProfileURL = config.get('auth:LETIteach:userProfileURL');
    this._oauth2._useAuthorizationHeaderForGET = true;
    this._oauth2.get(userProfileURL, accessToken, function(err, body, res) {
        if (err) {
            var InternalOAuthError = require('passport-oauth').InternalOAuthError;
            return done(new InternalOAuthError('failed to fetch user profile', err));
        }
        try {
            db.profile.auth.LETIteach(JSON.parse(body), done);
        }
        catch (e) {
            done(e);
        }
    });
}));
router.get('/LETIteach', passport.authenticate('LETIteach'));
router.get('/LETIteach/callback', passport.authenticate('LETIteach', {
    failureRedirect: '/#login'
}), router.logUserIP, function(req, res, next) {
    res.redirect('/');
});

config.js

"auth": {
        "LETIteach": {
            "authorizationURL": "https://open.etu.ru/oauth2/auth",
            "tokenURL": "https://open.etu.ru/oauth2/token",
            "userProfileURL": "https://open.edu.ru/oauth2/user_info",
            "clientID": "test",
            "clientSecret": "test",
            "callbackURL": "https://proctor.etu.ru/profile/LETIteach/callback",
            "scope": "openid profile email"
        },

db/index.js

LETIteach: function(prof, done) {
                var userData = {
                    username: prof.username,
                    provider: config.get('auth:LETIteach:provider') || 'LETIteach'
                };
                var User = require('./models/user');
                User.findOne({
                    username: userData.username,
                    provider: userData.provider
                }).exec(function(err, data) {
                    if (err) {
                        return done(err);
                    }
                    if (!data) {
                        var user = new User(userData);
                        user.save(function(err, data) {
                            return done(err, data);
                        });
                    }
                    else {
                        if (!data.isActive()) {
                            return done(null, false, {
                                message: 'User is inactive.'
                            });
                        }
                        return done(null, data);
                    }
                });
            },

Ситуация на данный момент. Ошибка прежняя

from itmoproctor.

meefik avatar meefik commented on June 18, 2024

Попробуйте связаться с разработчиками из ИТМО, они поддерживают форк https://github.com/openeduITMO/ITMOproctor
Я больше не занимаюсь поддержкой этого проекта.

from itmoproctor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.