mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Replace "register" with "sign up".
This commit is contained in:
parent
3793029491
commit
7a0ed4ebaf
@ -69,7 +69,7 @@ m = (r.subOwner == p.subOwner || p.subOwner == "*") && \
|
|||||||
if true {
|
if true {
|
||||||
ruleText := `
|
ruleText := `
|
||||||
p, built-in, *, *, *, *, *
|
p, built-in, *, *, *, *, *
|
||||||
p, *, *, POST, /api/register, *, *
|
p, *, *, POST, /api/signup, *, *
|
||||||
p, *, *, POST, /api/login, *, *
|
p, *, *, POST, /api/login, *, *
|
||||||
p, *, *, GET, /api/get-app-login, *, *
|
p, *, *, GET, /api/get-app-login, *, *
|
||||||
p, *, *, POST, /api/logout, *, *
|
p, *, *, POST, /api/logout, *, *
|
||||||
|
@ -54,13 +54,13 @@ type Response struct {
|
|||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title Register
|
// @Title Signup
|
||||||
// @Description register a new user
|
// @Description sign up a new user
|
||||||
// @Param username formData string true "The username to register"
|
// @Param username formData string true "The username to sign up"
|
||||||
// @Param password formData string true "The password"
|
// @Param password formData string true "The password"
|
||||||
// @Success 200 {object} controllers.Response The Response object
|
// @Success 200 {object} controllers.Response The Response object
|
||||||
// @router /register [post]
|
// @router /signup [post]
|
||||||
func (c *ApiController) Register() {
|
func (c *ApiController) Signup() {
|
||||||
var resp Response
|
var resp Response
|
||||||
|
|
||||||
if c.GetSessionUser() != "" {
|
if c.GetSessionUser() != "" {
|
||||||
@ -76,7 +76,7 @@ func (c *ApiController) Register() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := object.CheckUserRegister(form.Username, form.Password)
|
msg := object.CheckUserSignup(form.Username, form.Password)
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
resp = Response{Status: "error", Msg: msg, Data: ""}
|
resp = Response{Status: "error", Msg: msg, Data: ""}
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +94,7 @@ func (c *ApiController) Register() {
|
|||||||
|
|
||||||
//c.SetSessionUser(user)
|
//c.SetSessionUser(user)
|
||||||
|
|
||||||
util.LogInfo(c.Ctx, "API: [%s] is registered as new user", user)
|
util.LogInfo(c.Ctx, "API: [%s] is signed up as new user", user)
|
||||||
resp = Response{Status: "ok", Msg: "", Data: user}
|
resp = Response{Status: "ok", Msg: "", Data: user}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ func (c *ApiController) GetAccount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Title UploadAvatar
|
// @Title UploadAvatar
|
||||||
// @Description register a new user
|
// @Description upload avatar
|
||||||
// @Param avatarfile formData string true "The base64 encode of avatarfile"
|
// @Param avatarfile formData string true "The base64 encode of avatarfile"
|
||||||
// @Param password formData string true "The password"
|
// @Param password formData string true "The password"
|
||||||
// @Success 200 {object} controllers.Response The Response object
|
// @Success 200 {object} controllers.Response The Response object
|
||||||
|
@ -174,12 +174,12 @@ func (c *ApiController) Login() {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
if !application.EnableSignUp {
|
if !application.EnableSignUp {
|
||||||
resp = &Response{Status: "error", Msg: fmt.Sprintf("The account for provider: %s and username: %s does not exist and is not allowed to register as new account, please contact your IT support", provider.Type, userInfo.Username)}
|
resp = &Response{Status: "error", Msg: fmt.Sprintf("The account for provider: %s and username: %s does not exist and is not allowed to sign up as new account, please contact your IT support", provider.Type, userInfo.Username)}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
resp = &Response{Status: "error", Msg: fmt.Sprintf("The account for provider: %s and username: %s does not exist, please register an account first", provider.Type, userInfo.Username)}
|
resp = &Response{Status: "error", Msg: fmt.Sprintf("The account for provider: %s and username: %s does not exist, please create an account first", provider.Type, userInfo.Username)}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
|
@ -16,7 +16,7 @@ package object
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func CheckUserRegister(userId string, password string) string {
|
func CheckUserSignup(userId string, password string) string {
|
||||||
if len(userId) == 0 || len(password) == 0 {
|
if len(userId) == 0 || len(password) == 0 {
|
||||||
return "username and password cannot be blank"
|
return "username and password cannot be blank"
|
||||||
} else if HasUser(userId) {
|
} else if HasUser(userId) {
|
||||||
|
@ -39,7 +39,7 @@ func initAPI() {
|
|||||||
)
|
)
|
||||||
beego.AddNamespace(ns)
|
beego.AddNamespace(ns)
|
||||||
|
|
||||||
beego.Router("/api/register", &controllers.ApiController{}, "POST:Register")
|
beego.Router("/api/signup", &controllers.ApiController{}, "POST:Signup")
|
||||||
beego.Router("/api/login", &controllers.ApiController{}, "POST:Login")
|
beego.Router("/api/login", &controllers.ApiController{}, "POST:Login")
|
||||||
beego.Router("/api/get-app-login", &controllers.ApiController{}, "GET:GetApplicationLogin")
|
beego.Router("/api/get-app-login", &controllers.ApiController{}, "GET:GetApplicationLogin")
|
||||||
beego.Router("/api/logout", &controllers.ApiController{}, "POST:Logout")
|
beego.Router("/api/logout", &controllers.ApiController{}, "POST:Logout")
|
||||||
|
@ -33,7 +33,7 @@ import HomePage from "./basic/HomePage";
|
|||||||
import CustomGithubCorner from "./CustomGithubCorner";
|
import CustomGithubCorner from "./CustomGithubCorner";
|
||||||
|
|
||||||
import * as Auth from "./auth/Auth";
|
import * as Auth from "./auth/Auth";
|
||||||
import RegisterPage from "./auth/RegisterPage";
|
import SignupPage from "./auth/SignupPage";
|
||||||
import ResultPage from "./auth/ResultPage";
|
import ResultPage from "./auth/ResultPage";
|
||||||
import LoginPage from "./auth/LoginPage";
|
import LoginPage from "./auth/LoginPage";
|
||||||
import SelfLoginPage from "./auth/SelfLoginPage";
|
import SelfLoginPage from "./auth/SelfLoginPage";
|
||||||
@ -94,7 +94,7 @@ class App extends Component {
|
|||||||
this.setState({ selectedMenuKey: 4 });
|
this.setState({ selectedMenuKey: 4 });
|
||||||
} else if (uri.includes('tokens')) {
|
} else if (uri.includes('tokens')) {
|
||||||
this.setState({ selectedMenuKey: 5 });
|
this.setState({ selectedMenuKey: 5 });
|
||||||
} else if (uri.includes('register')) {
|
} else if (uri.includes('signup')) {
|
||||||
this.setState({ selectedMenuKey: 100 });
|
this.setState({ selectedMenuKey: 100 });
|
||||||
} else if (uri.includes('login')) {
|
} else if (uri.includes('login')) {
|
||||||
this.setState({ selectedMenuKey: 101 });
|
this.setState({ selectedMenuKey: 101 });
|
||||||
@ -214,8 +214,8 @@ class App extends Component {
|
|||||||
} else if (this.state.account === null) {
|
} else if (this.state.account === null) {
|
||||||
res.push(
|
res.push(
|
||||||
<Menu.Item key="100" style={{float: 'right', marginRight: '20px'}}>
|
<Menu.Item key="100" style={{float: 'right', marginRight: '20px'}}>
|
||||||
<Link to="/register">
|
<Link to="/signup">
|
||||||
{i18next.t("account:Register")}
|
{i18next.t("account:Sign Up")}
|
||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
);
|
);
|
||||||
@ -314,7 +314,7 @@ class App extends Component {
|
|||||||
|
|
||||||
isStartPages() {
|
isStartPages() {
|
||||||
return window.location.pathname.startsWith('/login') ||
|
return window.location.pathname.startsWith('/login') ||
|
||||||
window.location.pathname.startsWith('/register') ||
|
window.location.pathname.startsWith('/signup') ||
|
||||||
window.location.pathname === '/';
|
window.location.pathname === '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ class App extends Component {
|
|||||||
</Menu>
|
</Menu>
|
||||||
</Header>
|
</Header>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/register" render={(props) => this.renderHomeIfLoggedIn(<RegisterPage {...props} />)}/>
|
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...props} />)}/>
|
||||||
<Route exact path="/result" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
<Route exact path="/result" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
||||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...props} />)}/>
|
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...props} />)}/>
|
||||||
<Route exact path="/callback" component={AuthCallback}/>
|
<Route exact path="/callback" component={AuthCallback}/>
|
||||||
|
@ -22,8 +22,8 @@ export function getAccount(accessToken) {
|
|||||||
}).then(res => res.json());
|
}).then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function register(values) {
|
export function signup(values) {
|
||||||
return fetch(`${authConfig.serverUrl}/api/register`, {
|
return fetch(`${authConfig.serverUrl}/api/signup`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify(values),
|
body: JSON.stringify(values),
|
||||||
|
@ -210,7 +210,7 @@ class LoginPage extends React.Component {
|
|||||||
!application.enableSignUp ? null : (
|
!application.enableSignUp ? null : (
|
||||||
<div style={{float: "right"}}>
|
<div style={{float: "right"}}>
|
||||||
{i18next.t("login:No account yet?")}
|
{i18next.t("login:No account yet?")}
|
||||||
<Link to={"/register"}>
|
<Link to={"/signup"}>
|
||||||
{i18next.t("login:sign up now")}
|
{i18next.t("login:sign up now")}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
@ -250,7 +250,7 @@ class LoginPage extends React.Component {
|
|||||||
<br/>
|
<br/>
|
||||||
<div style={{float: "right"}}>
|
<div style={{float: "right"}}>
|
||||||
No account yet?
|
No account yet?
|
||||||
<Link to={"/register"}>
|
<Link to={"/signup"}>
|
||||||
sign up now
|
sign up now
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,7 +29,7 @@ class ResultPage extends React.Component {
|
|||||||
<div>
|
<div>
|
||||||
<Result
|
<Result
|
||||||
status="success"
|
status="success"
|
||||||
title="Your account is registered"
|
title="Your account is created"
|
||||||
subTitle="Please click the below button to login"
|
subTitle="Please click the below button to login"
|
||||||
extra={[
|
extra={[
|
||||||
<Link to="/login">
|
<Link to="/login">
|
||||||
|
@ -52,7 +52,7 @@ const tailFormItemLayout = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
class RegisterPage extends React.Component {
|
class SignupPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -63,12 +63,12 @@ class RegisterPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFinish(values) {
|
onFinish(values) {
|
||||||
AuthBackend.register(values)
|
AuthBackend.signup(values)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 'ok') {
|
if (res.status === 'ok') {
|
||||||
this.props.history.push('/result');
|
this.props.history.push('/result');
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", `Failed to register: ${res.msg}`);
|
Setting.showMessage("error", `Failed to sign up: ${res.msg}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ class RegisterPage extends React.Component {
|
|||||||
<Form
|
<Form
|
||||||
{...formItemLayout}
|
{...formItemLayout}
|
||||||
ref={this.form}
|
ref={this.form}
|
||||||
name="register"
|
name="signup"
|
||||||
onFinish={(values) => this.onFinish(values)}
|
onFinish={(values) => this.onFinish(values)}
|
||||||
onFinishFailed={(errorInfo) => this.onFinishFailed(errorInfo.values, errorInfo.errorFields, errorInfo.outOfDate)}
|
onFinishFailed={(errorInfo) => this.onFinishFailed(errorInfo.values, errorInfo.errorFields, errorInfo.outOfDate)}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
@ -249,4 +249,4 @@ class RegisterPage extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RegisterPage;
|
export default SignupPage;
|
@ -58,8 +58,8 @@ export function renderMessageLarge(ths, msg) {
|
|||||||
<Button key="home" onClick={() => Setting.goToLinkSoft(ths, "/")}>
|
<Button key="home" onClick={() => Setting.goToLinkSoft(ths, "/")}>
|
||||||
Home
|
Home
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button type="primary" key="register" onClick={() => Setting.goToLinkSoft(ths, "/register")}>
|
<Button type="primary" key="signup" onClick={() => Setting.goToLinkSoft(ths, "/signup")}>
|
||||||
Register
|
Sign Up
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
"Settings for your account": "Settings for your account",
|
"Settings for your account": "Settings for your account",
|
||||||
"Login": "Login",
|
"Login": "Login",
|
||||||
"Logout": "Logout",
|
"Logout": "Logout",
|
||||||
"Register": "Register"
|
"Sign Up": "Sign Up"
|
||||||
},
|
},
|
||||||
"organization":
|
"organization":
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
"Settings for your account": "账户设置选项",
|
"Settings for your account": "账户设置选项",
|
||||||
"Login": "登录",
|
"Login": "登录",
|
||||||
"Logout": "登出",
|
"Logout": "登出",
|
||||||
"Register": "注册"
|
"Sign Up": "注册"
|
||||||
},
|
},
|
||||||
"organization":
|
"organization":
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user