register
Create new user accounts in the JSON Database Server by providing name, email, password, department, position, and role details for system access.
Instructions
Yeni kullanıcı kaydı oluşturur
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Kullanıcı adı | |
| Yes | E-posta adresi | ||
| password | Yes | Şifre | |
| department | Yes | Departman | |
| position | Yes | Pozisyon | |
| role | No | Kullanıcı rolü |
Implementation Reference
- src/index.js:371-413 (handler)The core handler for the 'register' tool. Validates email uniqueness, hashes the password using hashPassword from auth.js, generates a new user ID, adds the user to the database, persists changes, and returns a success response with user details.
case 'register': { const { name: userName, email, password, department, position, role = 'employee' } = args; // E-posta kontrolü const existingUser = db.users.find(u => u.email === email); if (existingUser) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Bu e-posta adresi zaten kayıtlı' }) }] }; } // Şifreyi hash'le const hashedPassword = await hashPassword(password); // Yeni kullanıcı oluştur const newUser = { id: generateId(db.users), name: userName, email, password: hashedPassword, department, position, role, joinDate: new Date().toISOString().split('T')[0] }; db.users.push(newUser); await writeDatabase(db); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Kullanıcı başarıyla kaydedildi', user: { id: newUser.id, name: userName, email, role } }) }] }; } - src/index.js:65-82 (registration)The 'register' tool registration in the ListToolsRequestSchema response, including name, description, and input schema definition.
name: 'register', description: 'Yeni kullanıcı kaydı oluşturur', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, password: { type: 'string', description: 'Şifre' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, role: { type: 'string', enum: ['admin', 'manager', 'employee'], description: 'Kullanıcı rolü' } }, required: ['name', 'email', 'password', 'department', 'position'] } - src/index.js:67-82 (schema)Input schema definition for the 'register' tool, specifying required fields and types for user registration.
inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, password: { type: 'string', description: 'Şifre' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, role: { type: 'string', enum: ['admin', 'manager', 'employee'], description: 'Kullanıcı rolü' } }, required: ['name', 'email', 'password', 'department', 'position'] }