Skip to main content
Glama

login

Authenticate users to access the JSON Database Server by verifying email and password credentials, then receive a JWT token for secure API operations.

Instructions

Kullanıcı giriş yapar ve JWT token alır

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYesKullanıcı e-posta adresi
passwordYesKullanıcı şifresi

Implementation Reference

  • The main execution logic for the 'login' tool. Validates user credentials against the database, generates a JWT token upon successful authentication, handles errors for invalid users or passwords, and logs audit events.
    case 'login': { const { email, password } = args; // Kullanıcıyı bul const user = db.users.find(u => u.email === email); if (!user) { // Başarısız login denemesini logla await auditLogger.loginFailed(email, { reason: 'user_not_found' }); return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Kullanıcı bulunamadı' }) }] }; } // Şifreyi kontrol et const isPasswordValid = await comparePassword(password, user.password); if (!isPasswordValid) { // Başarısız login denemesini logla await auditLogger.loginFailed(email, { reason: 'invalid_password', userId: user.id }); return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Geçersiz şifre' }) }] }; } // JWT token oluştur const token = generateToken(user.id, user.email, user.role); // Başarılı login'i logla await auditLogger.loginSuccess(user.id, user.role, { email, loginTime: new Date().toISOString(), tokenGenerated: true }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Giriş başarılı', token, user: { id: user.id, name: user.name, email: user.email, role: user.role, department: user.department, position: user.position } }) }] }; }
  • The input schema definition for the 'login' tool, specifying required email and password fields. This is part of the tool list returned by ListToolsRequest.
    { name: 'login', description: 'Kullanıcı giriş yapar ve JWT token alır', inputSchema: { type: 'object', properties: { email: { type: 'string', description: 'Kullanıcı e-posta adresi' }, password: { type: 'string', description: 'Kullanıcı şifresi' } }, required: ['email', 'password'] } },
  • Helper functions for logging successful and failed login attempts to the audit log system, used within the login handler.
    loginSuccess: (userId, userRole, details = {}) => logAudit(userId, userRole, 'LOGIN_SUCCESS', AUDIT_CATEGORIES.AUTH, AUDIT_LEVELS.INFO, details), loginFailed: (email, details = {}) => logAudit(null, null, 'LOGIN_FAILED', AUDIT_CATEGORIES.AUTH, AUDIT_LEVELS.WARN, { email, ...details }),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yusuferenkt/mcp-database'

If you have feedback or need assistance with the MCP directory API, please join our Discord server