nodebb-plugin-sso-biogrenci 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +9 -0
- package/image.png +0 -0
- package/library.js +2 -0
- package/package.json +3 -3
- package/plugin.json +5 -0
- package/static/lib/account-biogrenci.js +72 -0
- package/static/lib/admin.js +29 -0
- package/static/lib/biogrenci-firsatlar.js +196 -0
- package/static/style.less +418 -96
- package/static/templates/account/biogrenci.tpl +0 -67
- package/static/templates/admin/plugins/sso-biogrenci.tpl +18 -19
- package/static/templates/biogrenci-firsatlar.tpl +18 -171
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(tree -L 3 -I 'node_modules' /c/Users/kadir/OneDrive/Masaüstü/Projeler/nodebb-plugin-sso-biogrenci/ 2>/dev/null || find /c/Users/kadir/OneDrive/Masaüstü/Projeler/nodebb-plugin-sso-biogrenci -not -path '*/node_modules/*' -type f | sort)",
|
|
5
|
+
"WebFetch(domain:raw.githubusercontent.com)",
|
|
6
|
+
"Bash(xargs grep:*)"
|
|
7
|
+
]
|
|
8
|
+
}
|
|
9
|
+
}
|
package/image.png
ADDED
|
Binary file
|
package/library.js
CHANGED
|
@@ -115,8 +115,10 @@ plugin.init = async function (params) {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
async function renderAdmin(req, res) {
|
|
118
|
+
const callbackURL = nconf.get('url') + '/auth/biogrenci/callback';
|
|
118
119
|
res.render('admin/plugins/sso-biogrenci', {
|
|
119
120
|
title: "bi'öğrenci SSO",
|
|
121
|
+
callbackURL: callbackURL,
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-sso-biogrenci",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "bi'öğrenci OAuth2 SSO login & öğrenci indirimleri for NodeBB",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"keywords": [
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"oauth2"
|
|
12
12
|
],
|
|
13
13
|
"nbbpm": {
|
|
14
|
-
"compatibility": "^3.2.0"
|
|
14
|
+
"compatibility": "^3.2.0 || ^4.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"passport-oauth2": "^1.8.0"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT"
|
|
20
|
-
}
|
|
20
|
+
}
|
package/plugin.json
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
"static": "./static"
|
|
7
7
|
},
|
|
8
8
|
"less": ["static/style.less"],
|
|
9
|
+
"modules": {
|
|
10
|
+
"../admin/plugins/sso-biogrenci.js": "static/lib/admin.js",
|
|
11
|
+
"../client/biogrenci-firsatlar.js": "static/lib/biogrenci-firsatlar.js",
|
|
12
|
+
"../client/account/biogrenci.js": "static/lib/account-biogrenci.js"
|
|
13
|
+
},
|
|
9
14
|
"hooks": [
|
|
10
15
|
{ "hook": "filter:auth.init", "method": "getStrategy" },
|
|
11
16
|
{ "hook": "filter:auth.list", "method": "listStrategy" },
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
define('forum/account/biogrenci', ['alerts'], function (alerts) {
|
|
4
|
+
var AccountPage = {};
|
|
5
|
+
|
|
6
|
+
AccountPage.init = function () {
|
|
7
|
+
loadStatus();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function loadStatus() {
|
|
11
|
+
fetch(config.relative_path + '/api/biogrenci/status')
|
|
12
|
+
.then(function (r) { return r.json(); })
|
|
13
|
+
.then(function (data) {
|
|
14
|
+
var $el = $('#biogrenci-status');
|
|
15
|
+
if (data.linked) {
|
|
16
|
+
$el.html(
|
|
17
|
+
'<div class="biogrenci-linked">' +
|
|
18
|
+
'<div class="biogrenci-linked-badge">' +
|
|
19
|
+
'<i class="fa fa-check-circle"></i> Hesap Bağlı' +
|
|
20
|
+
'</div>' +
|
|
21
|
+
(data.verified
|
|
22
|
+
? '<div class="biogrenci-verified-badge"><i class="fa fa-shield"></i> Doğrulanmış Öğrenci</div>'
|
|
23
|
+
: '') +
|
|
24
|
+
(data.education
|
|
25
|
+
? '<div class="biogrenci-education"><i class="fa fa-university"></i> ' + data.education + '</div>'
|
|
26
|
+
: '') +
|
|
27
|
+
'<hr/>' +
|
|
28
|
+
'<button id="biogrenci-unlink" class="btn btn-danger btn-sm">' +
|
|
29
|
+
'<i class="fa fa-unlink"></i> Bağlantıyı Kaldır' +
|
|
30
|
+
'</button>' +
|
|
31
|
+
'</div>'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
$('#biogrenci-unlink').on('click', unlinkAccount);
|
|
35
|
+
} else {
|
|
36
|
+
$el.html(
|
|
37
|
+
'<div class="biogrenci-not-linked">' +
|
|
38
|
+
'<p>bi\'öğrenci hesabınız henüz bağlı değil.</p>' +
|
|
39
|
+
'<p class="text-muted">Hesabınızı bağlayarak öğrenci doğrulaması yapabilir ve fırsatlardan yararlanabilirsiniz.</p>' +
|
|
40
|
+
'<a href="' + config.relative_path + '/auth/biogrenci" class="btn btn-primary">' +
|
|
41
|
+
'<i class="fa fa-graduation-cap"></i> bi\'öğrenci Hesabını Bağla' +
|
|
42
|
+
'</a>' +
|
|
43
|
+
'</div>'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function unlinkAccount() {
|
|
50
|
+
bootbox.confirm("bi'öğrenci hesap bağlantısını kaldırmak istediğinize emin misiniz?", function (ok) {
|
|
51
|
+
if (!ok) return;
|
|
52
|
+
fetch(config.relative_path + '/api/biogrenci/unlink', {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers: {
|
|
55
|
+
'x-csrf-token': config.csrf_token,
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
.then(function (r) { return r.json(); })
|
|
60
|
+
.then(function (res) {
|
|
61
|
+
if (res.success) {
|
|
62
|
+
alerts.success("bi'öğrenci bağlantısı kaldırıldı");
|
|
63
|
+
loadStatus();
|
|
64
|
+
} else {
|
|
65
|
+
alerts.error(res.error || 'Bir hata oluştu');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return AccountPage;
|
|
72
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
define('admin/plugins/sso-biogrenci', ['settings'], function (Settings) {
|
|
4
|
+
var ACP = {};
|
|
5
|
+
|
|
6
|
+
ACP.init = function () {
|
|
7
|
+
Settings.load('sso-biogrenci', $('.sso-biogrenci-settings'));
|
|
8
|
+
|
|
9
|
+
$('#save').on('click', function () {
|
|
10
|
+
Settings.save('sso-biogrenci', $('.sso-biogrenci-settings'), function () {
|
|
11
|
+
app.alertSuccess('Ayarlar kaydedildi!');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
$('#toggleSecret').on('click', function () {
|
|
16
|
+
var input = $('#clientSecret');
|
|
17
|
+
var icon = $(this).find('i');
|
|
18
|
+
if (input.attr('type') === 'password') {
|
|
19
|
+
input.attr('type', 'text');
|
|
20
|
+
icon.removeClass('fa-eye').addClass('fa-eye-slash');
|
|
21
|
+
} else {
|
|
22
|
+
input.attr('type', 'password');
|
|
23
|
+
icon.removeClass('fa-eye-slash').addClass('fa-eye');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return ACP;
|
|
29
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
define('forum/biogrenci-firsatlar', ['alerts'], function (alerts) {
|
|
4
|
+
var Page = {};
|
|
5
|
+
|
|
6
|
+
var currentPage = 1;
|
|
7
|
+
var currentType = '';
|
|
8
|
+
var currentSort = 'featured';
|
|
9
|
+
var currentSearch = '';
|
|
10
|
+
var searchTimeout = null;
|
|
11
|
+
|
|
12
|
+
Page.init = function () {
|
|
13
|
+
loadOpportunities();
|
|
14
|
+
|
|
15
|
+
// Filter buttons
|
|
16
|
+
$('.biogrenci-filter').on('click', function () {
|
|
17
|
+
$('.biogrenci-filter').removeClass('active');
|
|
18
|
+
$(this).addClass('active');
|
|
19
|
+
currentType = $(this).attr('data-type');
|
|
20
|
+
currentPage = 1;
|
|
21
|
+
loadOpportunities();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Sort
|
|
25
|
+
$('#biogrenci-sort').on('change', function () {
|
|
26
|
+
currentSort = $(this).val();
|
|
27
|
+
currentPage = 1;
|
|
28
|
+
loadOpportunities();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Search with debounce
|
|
32
|
+
$('#biogrenci-search').on('input', function () {
|
|
33
|
+
clearTimeout(searchTimeout);
|
|
34
|
+
var val = $(this).val();
|
|
35
|
+
searchTimeout = setTimeout(function () {
|
|
36
|
+
currentSearch = val;
|
|
37
|
+
currentPage = 1;
|
|
38
|
+
loadOpportunities();
|
|
39
|
+
}, 400);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Pagination
|
|
43
|
+
$('#biogrenci-prev').on('click', function () {
|
|
44
|
+
if (currentPage > 1) {
|
|
45
|
+
currentPage--;
|
|
46
|
+
loadOpportunities();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
$('#biogrenci-next').on('click', function () {
|
|
51
|
+
currentPage++;
|
|
52
|
+
loadOpportunities();
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function loadOpportunities() {
|
|
57
|
+
var $list = $('#biogrenci-list');
|
|
58
|
+
$list.html(
|
|
59
|
+
'<div class="biogrenci-loading">' +
|
|
60
|
+
'<div class="biogrenci-spinner"></div>' +
|
|
61
|
+
'<p>Fırsatlar yükleniyor...</p>' +
|
|
62
|
+
'</div>'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
var params = new URLSearchParams({
|
|
66
|
+
page: currentPage,
|
|
67
|
+
per_page: 20,
|
|
68
|
+
sort: currentSort,
|
|
69
|
+
});
|
|
70
|
+
if (currentType) params.set('type', currentType);
|
|
71
|
+
if (currentSearch) params.set('search', currentSearch);
|
|
72
|
+
|
|
73
|
+
fetch(config.relative_path + '/api/biogrenci/firsatlar?' + params.toString())
|
|
74
|
+
.then(function (r) { return r.json(); })
|
|
75
|
+
.then(function (res) {
|
|
76
|
+
if (!res.data || !res.data.length) {
|
|
77
|
+
$list.html(
|
|
78
|
+
'<div class="biogrenci-empty">' +
|
|
79
|
+
'<i class="fa fa-search fa-3x"></i>' +
|
|
80
|
+
'<h4>Fırsat bulunamadı</h4>' +
|
|
81
|
+
'<p>Farklı filtreler deneyebilirsiniz</p>' +
|
|
82
|
+
'</div>'
|
|
83
|
+
);
|
|
84
|
+
$('#biogrenci-pagination').hide();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
renderOpportunities(res.data);
|
|
88
|
+
renderPagination(res.meta || {});
|
|
89
|
+
})
|
|
90
|
+
.catch(function () {
|
|
91
|
+
$list.html(
|
|
92
|
+
'<div class="biogrenci-empty biogrenci-error">' +
|
|
93
|
+
'<i class="fa fa-exclamation-triangle fa-3x"></i>' +
|
|
94
|
+
'<h4>Fırsatlar yüklenirken hata oluştu</h4>' +
|
|
95
|
+
'<p>Lütfen daha sonra tekrar deneyin</p>' +
|
|
96
|
+
'</div>'
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function renderOpportunities(items) {
|
|
102
|
+
var $list = $('#biogrenci-list');
|
|
103
|
+
var html = items.map(function (item) {
|
|
104
|
+
var typeLabel = item.type === 'kupon' ? 'Kupon' : item.type === 'qr' ? 'QR Kod' : 'Link';
|
|
105
|
+
var typeBadge = item.type === 'kupon' ? 'badge-kupon' : item.type === 'qr' ? 'badge-qr' : 'badge-affiliate';
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
'<div class="biogrenci-card">' +
|
|
109
|
+
(item.image
|
|
110
|
+
? '<div class="biogrenci-card-img"><img src="' + item.image + '" alt="' + (item.brand_name || '') + '" loading="lazy"></div>'
|
|
111
|
+
: '<div class="biogrenci-card-img biogrenci-card-img-placeholder"><i class="fa fa-gift fa-3x"></i></div>') +
|
|
112
|
+
'<div class="biogrenci-card-body">' +
|
|
113
|
+
'<div class="biogrenci-card-top">' +
|
|
114
|
+
'<span class="biogrenci-badge ' + typeBadge + '">' + typeLabel + '</span>' +
|
|
115
|
+
(item.brand_name ? '<span class="biogrenci-brand">' + item.brand_name + '</span>' : '') +
|
|
116
|
+
'</div>' +
|
|
117
|
+
'<h3 class="biogrenci-card-title">' + item.title + '</h3>' +
|
|
118
|
+
(item.description ? '<p class="biogrenci-card-desc">' + item.description + '</p>' : '') +
|
|
119
|
+
'<button class="btn biogrenci-claim-btn" data-id="' + item.id + '">' +
|
|
120
|
+
'<i class="fa fa-hand-pointer-o"></i> Fırsatı Al' +
|
|
121
|
+
'</button>' +
|
|
122
|
+
'</div>' +
|
|
123
|
+
'</div>'
|
|
124
|
+
);
|
|
125
|
+
}).join('');
|
|
126
|
+
|
|
127
|
+
$list.html(html);
|
|
128
|
+
|
|
129
|
+
// Bind claim buttons
|
|
130
|
+
$list.find('.biogrenci-claim-btn').on('click', function () {
|
|
131
|
+
claimOpportunity($(this));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function renderPagination(meta) {
|
|
136
|
+
var $el = $('#biogrenci-pagination');
|
|
137
|
+
if (!meta.total || meta.total <= 20) {
|
|
138
|
+
$el.hide();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
$el.show();
|
|
142
|
+
var totalPages = Math.ceil(meta.total / 20);
|
|
143
|
+
$('#biogrenci-page-info').text(currentPage + ' / ' + totalPages);
|
|
144
|
+
$('#biogrenci-prev').prop('disabled', currentPage <= 1);
|
|
145
|
+
$('#biogrenci-next').prop('disabled', currentPage >= totalPages);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function claimOpportunity($btn) {
|
|
149
|
+
var id = $btn.attr('data-id');
|
|
150
|
+
$btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Alınıyor...');
|
|
151
|
+
|
|
152
|
+
fetch(config.relative_path + '/api/biogrenci/firsatlar/' + id + '/claim', {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: {
|
|
155
|
+
'x-csrf-token': config.csrf_token,
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
.then(function (r) { return r.json(); })
|
|
160
|
+
.then(function (res) {
|
|
161
|
+
if (res.error) {
|
|
162
|
+
alerts.error(res.error);
|
|
163
|
+
$btn.prop('disabled', false).html('<i class="fa fa-hand-pointer-o"></i> Fırsatı Al');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (res.data && res.data.coupon_code) {
|
|
167
|
+
$btn.replaceWith(
|
|
168
|
+
'<div class="biogrenci-coupon-result">' +
|
|
169
|
+
'<code class="biogrenci-coupon-code">' + res.data.coupon_code + '</code>' +
|
|
170
|
+
'<button class="btn btn-sm biogrenci-copy-btn" data-code="' + res.data.coupon_code + '">' +
|
|
171
|
+
'<i class="fa fa-copy"></i>' +
|
|
172
|
+
'</button>' +
|
|
173
|
+
(res.data.redirect_url
|
|
174
|
+
? '<a href="' + res.data.redirect_url + '" target="_blank" rel="noopener" class="btn btn-sm biogrenci-go-btn">Siteye Git <i class="fa fa-external-link"></i></a>'
|
|
175
|
+
: '') +
|
|
176
|
+
'</div>'
|
|
177
|
+
);
|
|
178
|
+
$('.biogrenci-copy-btn').last().on('click', function () {
|
|
179
|
+
navigator.clipboard.writeText($(this).attr('data-code'));
|
|
180
|
+
alerts.success('Kopyalandı!');
|
|
181
|
+
});
|
|
182
|
+
} else if (res.data && res.data.qr_code) {
|
|
183
|
+
$btn.replaceWith('<div class="biogrenci-qr-result">' + res.data.qr_code + '</div>');
|
|
184
|
+
} else if (res.data && res.data.redirect_url) {
|
|
185
|
+
window.open(res.data.redirect_url, '_blank');
|
|
186
|
+
$btn.html('<i class="fa fa-check"></i> Açıldı').addClass('claimed');
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
.catch(function () {
|
|
190
|
+
alerts.error('Bir hata oluştu');
|
|
191
|
+
$btn.prop('disabled', false).html('<i class="fa fa-hand-pointer-o"></i> Fırsatı Al');
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return Page;
|
|
196
|
+
});
|