Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
feat: add auto-redirect-login setting with dynamic config synchronization (v1.0.7)
This commit is contained in:
@@ -109,13 +109,87 @@ async function register({ registerExternalAuth, registerSetting, settingsManager
|
||||
default: 'https://auth.yakhub.com.tr'
|
||||
});
|
||||
|
||||
registerSetting({
|
||||
name: 'auto-redirect-login',
|
||||
label: 'Giriş Sayfasında Doğrudan YakNet SSO\'ya Yönlendir',
|
||||
type: 'input-checkbox',
|
||||
description: 'Aktif olduğunda, kullanıcılar giriş butonuna veya /login sayfasına gittiğinde standart PeerTube şifre formu yerine doğrudan YakNet SSO sunucusuna yönlendirilir.',
|
||||
private: false,
|
||||
default: true
|
||||
});
|
||||
|
||||
let autoRedirectLogin = true;
|
||||
|
||||
function syncConfigFiles(enable) {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 1. Update local-production.json if present
|
||||
const jsonCandidates = [
|
||||
path.resolve(process.cwd(), 'config', 'local-production.json'),
|
||||
path.resolve(__dirname, '..', '..', 'config', 'local-production.json'),
|
||||
path.resolve(__dirname, '..', '..', '..', 'config', 'local-production.json'),
|
||||
'c:/laragon/www/yaktube.yakhub.com.tr/config/local-production.json'
|
||||
];
|
||||
for (const jPath of jsonCandidates) {
|
||||
if (fs.existsSync(jPath)) {
|
||||
try {
|
||||
const cfg = JSON.parse(fs.readFileSync(jPath, 'utf8'));
|
||||
if (!cfg.menu) cfg.menu = {};
|
||||
if (!cfg.menu.login) cfg.menu.login = {};
|
||||
if (cfg.menu.login.redirect_on_single_external_auth !== enable) {
|
||||
cfg.menu.login.redirect_on_single_external_auth = enable;
|
||||
fs.writeFileSync(jPath, JSON.stringify(cfg, null, 2), 'utf8');
|
||||
logger.info(`[YakNet SSO] Synced local-production.json redirect_on_single_external_auth = ${enable}`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn('[YakNet SSO] Error updating local-production.json:', e.message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Update production.yaml if present
|
||||
const yamlCandidates = [
|
||||
path.resolve(process.cwd(), 'config', 'production.yaml'),
|
||||
path.resolve(__dirname, '..', '..', 'config', 'production.yaml'),
|
||||
path.resolve(__dirname, '..', '..', '..', 'config', 'production.yaml'),
|
||||
'c:/laragon/www/yaktube.yakhub.com.tr/config/production.yaml'
|
||||
];
|
||||
for (const yPath of yamlCandidates) {
|
||||
if (fs.existsSync(yPath)) {
|
||||
try {
|
||||
let yContent = fs.readFileSync(yPath, 'utf8');
|
||||
const pattern = /(redirect_on_single_external_auth:\s*)(true|false)/;
|
||||
if (pattern.test(yContent)) {
|
||||
const updated = yContent.replace(pattern, `$1${enable}`);
|
||||
if (updated !== yContent) {
|
||||
fs.writeFileSync(yPath, updated, 'utf8');
|
||||
logger.info(`[YakNet SSO] Synced production.yaml redirect_on_single_external_auth = ${enable}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn('[YakNet SSO] Error updating production.yaml:', e.message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSettings() {
|
||||
const cid = await settingsManager.getSetting('client-id');
|
||||
const csec = await settingsManager.getSetting('client-secret');
|
||||
const burl = await settingsManager.getSetting('auth-base-url');
|
||||
const autoRedir = await settingsManager.getSetting('auto-redirect-login');
|
||||
if (cid) clientId = cid;
|
||||
if (csec) clientSecret = csec;
|
||||
if (burl) authBaseUrl = burl.replace(/\/+$/, '');
|
||||
if (autoRedir !== undefined && autoRedir !== null) {
|
||||
autoRedirectLogin = autoRedir === true || autoRedir === 'true';
|
||||
} else {
|
||||
autoRedirectLogin = true;
|
||||
}
|
||||
syncConfigFiles(autoRedirectLogin);
|
||||
}
|
||||
await loadSettings();
|
||||
settingsManager.onSettingsChange(loadSettings);
|
||||
@@ -135,6 +209,12 @@ async function register({ registerExternalAuth, registerSetting, settingsManager
|
||||
|
||||
const router = getRouter();
|
||||
|
||||
router.get('/status', (req, res) => {
|
||||
return res.json({
|
||||
autoRedirectLogin: autoRedirectLogin !== false
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/auth', (req, res) => {
|
||||
const state = crypto.randomBytes(16).toString('hex');
|
||||
const authUrl = `${authBaseUrl}/oauth/authorize?client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(callbackUrl)}&response_type=code&scope=&state=${state}`;
|
||||
|
||||
Reference in New Issue
Block a user