@@ -4,29 +4,38 @@ const authenticateByProfile = require('../lib/authenticateByProfile');
44const config = require ( 'config' ) ;
55
66/*
7- {
8- provider: 'yandex',
9- id: '73404',
10- username: 'nlpstudent',
11- displayName: 'nlpstudent',
12- name: { familyName: 'Ilia', givenName: 'Kantor' },
13- gender: 'male',
14- emails: [
15- [Object]
16- ],
17- _raw: '{"first_name": "Ilia", "last_name": "Kantor", "display_name": "nlpstudent", "emails": ["nlpstudent@yandex .ru"], "default_email": "[email protected] ", "real_name": "Ilia Kantor", "login": "nlpstudent", "sex": "male", "id": "73404"}', 18- _json: { first_name: 'Ilia',
19- last_name: 'Kantor',
20- display_name: 'nlpstudent',
21- emails: [Object],
22- default_email: 'nlpstudent@yandex .ru',
23- real_name: 'Ilia Kantor',
24- login: 'nlpstudent',
25- sex: 'male',
26- id: '73404'
27- }
28- }
29- // No avatar here :(
7+ profile: {
8+ "provider": "yandex",
9+ "id": "11111",
10+ "username": "iliakan",
11+ "displayName": "iliakan",
12+ "name": {
13+ "familyName": "Ilya",
14+ "givenName": "Kantor"
15+ },
16+ "gender": "male",
17+ "emails": [
18+ {
19+ "value": "login@yandex .ru"
20+ }
21+ ],
22+ "_raw": "{\"first_name\": \"Ilya\", \"last_name\": \"Kantor\", \"display_name\": \"iliakan\", \"emails\": [\"login@yandex .ru\"], \"default_email\": \"[email protected] \", \"real_name\": \"Ilya Kantor\", \"default_avatar_id\": \"11111\", \"login\": \"login\", \"sex\": \"male\", \"id\": \"11111\"}", 23+ "_json": {
24+ "first_name": "Ilya",
25+ "last_name": "Kantor",
26+ "display_name": "iliakan",
27+ "emails": [
28+ "login@yandex .ru"
29+ ],
30+ "default_email": "[email protected] ", 31+ "real_name": "Ilya Kantor",
32+ "default_avatar_id": "11111",
33+ "login": "login",
34+ "sex": "male",
35+ "id": "11111"
36+ },
37+ "realName": "Ilya Kantor"
38+ }
3039*/
3140
3241module . exports = new YandexStrategy ( {
@@ -39,6 +48,12 @@ module.exports = new YandexStrategy({
3948 /* jshint -W106 */
4049 profile . realName = profile . _json . real_name ;
4150
51+ // there is no way to know if it is a default avatar or not
52+ // if user has no avatar, this gives us the "default yandex blank avatar"
53+ profile . photos = [ {
54+ value : `https://avatars.yandex.net/get-yapic/${ profile . _json . default_avatar_id } /islands-200`
55+ } ] ;
56+
4257 authenticateByProfile ( req , profile , done ) ;
4358 }
4459) ;
0 commit comments