Skip to content

Commit 03692e9

Browse files
committed
minor auth fixes
1 parent aa8ab60 commit 03692e9

13 files changed

Lines changed: 57 additions & 26 deletions

File tree

docs/logo/logo_big.png

47 KB
Loading

docs/logo/logo_big_square.png

56.7 KB
Loading

docs/logo/logo_interkassa.png

11.9 KB
Loading

docs/logo/logo_paypal_90x250.png

14.5 KB
Loading

docs/logo/logo_vk_150x150.png

6.59 KB
Loading

docs/logo/logo_vk_16x16.png

3.58 KB
Loading

docs/payment.sketch

0 Bytes
Binary file not shown.

handlers/auth/strategies/facebookStrategy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const co = require('co');
99
Returns fields:
1010
{
1111
"id": "765813916814019",
12-
"email": "nlpstudent\u0040mail.ru",
12+
"email": "login\u0040mail.ru",
1313
"gender": "male",
1414
"link": "https:\/\/www.facebook.com\/app_scoped_user_id\/765813916814019\/",
1515
"locale": "ru_RU",

handlers/auth/strategies/yandexStrategy.js

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,38 @@ const authenticateByProfile = require('../lib/authenticateByProfile');
44
const 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

3241
module.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
);

handlers/auth/templates/login-form.jade

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ include /bem
66
+e('h4').title Вход в систему
77
+e.header-aside
88
+e('button').button-link.__register(type="button" data-switch="register-form") регистрация
9+
10+
+e.line.__notification
11+
+e.info
12+
| Авторизация работает в тестовом режиме. О любых проблемах и странностях сообщайте, пожалуйста, на <a href="https://github.com/iliakan/javascript-nodejs/issues/new">github</a>.
13+
914
+e.line.__notification(data-notification)
15+
1016
+e.line
1117
+e('label').label(for="auth-email") Email:
1218
+b('span').text-input.__input

0 commit comments

Comments
 (0)