change_password
Update user password securely in the MCP JSON Database Server. Requires JWT token, old password, and new password for authentication and verification.
Instructions
Kullanıcı şifresini değiştirir
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| newPassword | Yes | Yeni şifre | |
| oldPassword | Yes | Mevcut şifre | |
| token | Yes | JWT token |
Implementation Reference
- src/index.js:501-546 (handler)Handler for change_password tool: verifies JWT token, finds user, validates old password using comparePassword, hashes new password with hashPassword, updates user in database, logs the change implicitly via database write.case 'change_password': { const { token, oldPassword, newPassword } = args; try { const decoded = verifyToken(token); const user = db.users.find(u => u.id === decoded.userId); if (!user) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Kullanıcı bulunamadı' }) }] }; } // Eski şifreyi kontrol et const isOldPasswordValid = await comparePassword(oldPassword, user.password); if (!isOldPasswordValid) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Mevcut şifre yanlış' }) }] }; } // Yeni şifreyi hash'le ve güncelle user.password = await hashPassword(newPassword); await writeDatabase(db); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Şifre başarıyla değiştirildi' }) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message }) }] }; } }
- src/index.js:107-119 (registration)Tool registration in ListToolsRequestSchema handler, defining the name, description, and input schema for change_password tool.{ name: 'change_password', description: 'Kullanıcı şifresini değiştirir', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, oldPassword: { type: 'string', description: 'Mevcut şifre' }, newPassword: { type: 'string', description: 'Yeni şifre' } }, required: ['token', 'oldPassword', 'newPassword'] } },
- src/index.js:110-118 (schema)Input schema definition for the change_password tool, specifying parameters: token, oldPassword, newPassword.inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, oldPassword: { type: 'string', description: 'Mevcut şifre' }, newPassword: { type: 'string', description: 'Yeni şifre' } }, required: ['token', 'oldPassword', 'newPassword'] }