Enhance ESLint configuration for TypeScript and React, update dependencies, and add new super admin setup script. Update README for improved clarity on superuser setup options and modify user interface components for better user experience.
This commit is contained in:
@ -7,6 +7,9 @@ export interface AdminUser {
|
||||
displayName: string;
|
||||
avatarUrl?: string;
|
||||
bio?: string;
|
||||
website?: string;
|
||||
location?: string;
|
||||
company?: string;
|
||||
isAdmin: boolean;
|
||||
isModerator: boolean;
|
||||
isSuperUser: boolean;
|
||||
@ -101,3 +104,47 @@ export function canViewAnalytics(user: AdminUser | null): boolean {
|
||||
export function canConfigureSystem(user: AdminUser | null): boolean {
|
||||
return hasPermission(user, 'system:configure');
|
||||
}
|
||||
|
||||
export function createOliverSuperAdmin(): AdminUser {
|
||||
return {
|
||||
id: generateId(),
|
||||
email: 'oliver@scriptshare.com',
|
||||
username: 'oliver',
|
||||
displayName: 'Oliver',
|
||||
avatarUrl: 'https://api.dicebear.com/7.x/avataaars/svg?seed=oliver',
|
||||
bio: 'Founder and Super Administrator of ScriptShare',
|
||||
website: 'https://scriptshare.com',
|
||||
location: 'Digital Realm',
|
||||
company: 'ScriptShare',
|
||||
isAdmin: true,
|
||||
isModerator: true,
|
||||
isSuperUser: true,
|
||||
permissions: [...SUPER_USER_PERMISSIONS],
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
// Browser-based function to set up Oliver super admin
|
||||
export function setupOliverInBrowser(): AdminUser {
|
||||
try {
|
||||
const oliverAdmin = createOliverSuperAdmin();
|
||||
|
||||
// Save to localStorage
|
||||
localStorage.setItem('scriptshare-user-data', JSON.stringify(oliverAdmin));
|
||||
localStorage.setItem('scriptshare-auth-token', Math.random().toString(36).substring(2) + Date.now().toString(36));
|
||||
|
||||
// Also add to admin users list
|
||||
const existingUsers = JSON.parse(localStorage.getItem('scriptshare-admin-users') || '[]');
|
||||
existingUsers.push(oliverAdmin);
|
||||
localStorage.setItem('scriptshare-admin-users', JSON.stringify(existingUsers));
|
||||
|
||||
console.log('✅ Oliver Super Admin setup complete in browser!');
|
||||
console.log('Refresh the page to log in as Oliver Super Admin');
|
||||
|
||||
return oliverAdmin;
|
||||
} catch (error) {
|
||||
console.error('❌ Error setting up Oliver Super Admin:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ export function debounce<T extends (...args: any[]) => any>(
|
||||
func: T,
|
||||
wait: number
|
||||
): (...args: Parameters<T>) => void {
|
||||
let timeout: NodeJS.Timeout;
|
||||
let timeout: ReturnType<typeof setTimeout>;
|
||||
return (...args: Parameters<T>) => {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func(...args), wait);
|
||||
@ -107,7 +107,7 @@ export function copyToClipboard(text: string): Promise<boolean> {
|
||||
document.execCommand('copy');
|
||||
textArea.remove();
|
||||
return Promise.resolve(true);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
textArea.remove();
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user