mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-28 15:54:56 +00:00
code: nextjs,frontends,auth (4 files)
This commit is contained in:
39
dbal/cpp/src/validation/package_validation.hpp
Normal file
39
dbal/cpp/src/validation/package_validation.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file package_validation.hpp
|
||||
* @brief Validation functions for Package entity
|
||||
*/
|
||||
#ifndef DBAL_PACKAGE_VALIDATION_HPP
|
||||
#define DBAL_PACKAGE_VALIDATION_HPP
|
||||
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
namespace dbal {
|
||||
namespace validation {
|
||||
|
||||
/**
|
||||
* Validate package name (1-255 characters)
|
||||
*/
|
||||
inline bool isValidPackageName(const std::string& name) {
|
||||
return !name.empty() && name.length() <= 255;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate semver version format (X.Y.Z)
|
||||
*/
|
||||
inline bool isValidSemver(const std::string& version) {
|
||||
static const std::regex semver_pattern(R"(^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$)");
|
||||
return std::regex_match(version, semver_pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate package key from name and version
|
||||
*/
|
||||
inline std::string packageKey(const std::string& name, const std::string& version) {
|
||||
return name + "@" + version;
|
||||
}
|
||||
|
||||
} // namespace validation
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@ import { Box } from '@mui/material'
|
||||
import type { BoxProps } from '@mui/material'
|
||||
import { TabsContext } from './tabs-context'
|
||||
|
||||
export interface TabsListProps extends BoxProps {}
|
||||
export type TabsListProps = BoxProps
|
||||
|
||||
const TabsList = forwardRef<HTMLDivElement, TabsListProps>(
|
||||
({ children, sx, ...props }, ref) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { User } from '@/lib/level-types'
|
||||
import { fetchSession } from '@/lib/auth/api/fetch-session'
|
||||
import { login as loginRequest } from '@/lib/auth/api/login'
|
||||
import { logout as logoutRequest } from '@/lib/auth/api/logout'
|
||||
import { register as registerRequest } from '@/lib/auth/api/register'
|
||||
import type { AuthState, AuthUser } from './auth-types'
|
||||
|
||||
const roleLevels: Record<string, number> = {
|
||||
@@ -64,6 +65,28 @@ export class AuthStore {
|
||||
}
|
||||
}
|
||||
|
||||
async register(username: string, email: string, password: string): Promise<void> {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isLoading: true,
|
||||
})
|
||||
|
||||
try {
|
||||
const user = await registerRequest(username, email, password)
|
||||
this.setState({
|
||||
user: this.mapUserToAuthUser(user),
|
||||
isAuthenticated: true,
|
||||
isLoading: false,
|
||||
})
|
||||
} catch (error) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isLoading: false,
|
||||
})
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async logout(): Promise<void> {
|
||||
this.setState({
|
||||
...this.state,
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface AuthState {
|
||||
|
||||
export interface UseAuthReturn extends AuthState {
|
||||
login: (identifier: string, password: string) => Promise<void>
|
||||
register: (username: string, email: string, password: string) => Promise<void>
|
||||
logout: () => Promise<void>
|
||||
refresh: () => Promise<void>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user