Generate authentication system with user model, sessions controller, and password hashing. Use when implementing user authentication, login/logout, or session management. Provides secure authentication patterns and bcrypt support.
Activate when:
component extends="Model" {
function config() {
validatesPresenceOf(property="email,password");
validatesUniquenessOf(property="email");
validatesFormatOf(
property="email",
regEx="^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$"
);
validatesLengthOf(property="password", minimum=8);
validatesConfirmationOf(property="password");
beforeSave("hashPassword");
}
private function hashPassword() {
if (structKeyExists(this, "password") && len(this.password) && !isHashed(this.password)) {
this.password = hash(this.password, "SHA-512");
}
}
private boolean function isHashed(required string password) {
return len(arguments.password) == 128;
}
public any function authenticate(required string email, required string password) {
var user = this.findOne(where="email = '#arguments.email#'");
if (!isObject(user)) return false;
var hashedAttempt = hash(arguments.password, "SHA-512");
return (user.password == hashedAttempt) ? user : false;
}
}
component extends="Controller" {
function new() {
// Show login form
}
function create() {
var user = model("User").authenticate(
email=params.email,
password=params.password
);
if (isObject(user)) {
session.userId = user.id;
flashInsert(success="Welcome back!");
redirectTo(controller="home", action="index");
} else {
flashInsert(error="Invalid email or password");
renderPage(action="new");
}
}
function delete() {
structDelete(session, "userId");
flashInsert(success="You have been logged out");
redirectTo(controller="home", action="index");
}
}
// In any controller requiring authentication
function config() {
filters(through="requireAuth");
}
private function requireAuth() {
if (!structKeyExists(session, "userId")) {
flashInsert(error="Please log in");
redirectTo(controller="sessions", action="new");
}
}
Generated by: Wheels Auth Generator Skill v1.0
npx skills add wheels-dev/Wheels Auth Generator下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer