feat: 注册邀请码模式
This commit is contained in:
parent
dd86bb88c6
commit
91f25e9ec3
@ -31,7 +31,7 @@ class UsersController extends AbstractController
|
|||||||
* @apiParam {String} email 邮箱
|
* @apiParam {String} email 邮箱
|
||||||
* @apiParam {String} password 密码
|
* @apiParam {String} password 密码
|
||||||
* @apiParam {String} [code] 登录验证码
|
* @apiParam {String} [code] 登录验证码
|
||||||
* @apiParam {String} [key] 登陆验证码key
|
* @apiParam {String} [invite] 注册邀请码
|
||||||
*
|
*
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
@ -46,24 +46,22 @@ class UsersController extends AbstractController
|
|||||||
$setting = Base::setting('system');
|
$setting = Base::setting('system');
|
||||||
if ($setting['reg'] == 'close') {
|
if ($setting['reg'] == 'close') {
|
||||||
return Base::retError('未开放注册');
|
return Base::retError('未开放注册');
|
||||||
|
} elseif ($setting['reg'] == 'invite') {
|
||||||
|
$invite = trim(Request::input('invite'));
|
||||||
|
if (empty($invite) || $invite != $setting['reg_invite']) {
|
||||||
|
return Base::retError('请输入正确的邀请码');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$user = User::reg($email, $password);
|
$user = User::reg($email, $password);
|
||||||
} else {
|
} else {
|
||||||
$needCode = !Base::isError(User::needCode($email));
|
$needCode = !Base::isError(User::needCode($email));
|
||||||
if ($needCode) {
|
if ($needCode) {
|
||||||
$code = trim(Request::input('code'));
|
$code = trim(Request::input('code'));
|
||||||
$key = trim(Request::input('key'));
|
|
||||||
if (empty($code)) {
|
if (empty($code)) {
|
||||||
return Base::retError('请输入验证码', ['code' => 'need']);
|
return Base::retError('请输入验证码', ['code' => 'need']);
|
||||||
}
|
}
|
||||||
if (empty($key)) {
|
if (!Captcha::check($code)) {
|
||||||
if (!Captcha::check($code)) {
|
return Base::retError('请输入正确的验证码', ['code' => 'need']);
|
||||||
return Base::retError('请输入正确的验证码', ['code' => 'need']);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!Captcha::check_api($code, $key)) {
|
|
||||||
return Base::retError('请输入正确的验证码', ['code' => 'need']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -154,6 +152,25 @@ class UsersController extends AbstractController
|
|||||||
return Base::retSuccess('请求成功', $captcha);
|
return Base::retSuccess('请求成功', $captcha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} api/users/reg/needinvite 04. 是否需要邀请码
|
||||||
|
*
|
||||||
|
* @apiDescription 用于判断注册是否需要邀请码
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiGroup users
|
||||||
|
* @apiName reg__needinvite
|
||||||
|
*
|
||||||
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
|
* @apiSuccess {Object} data 返回数据
|
||||||
|
*/
|
||||||
|
public function reg__needinvite()
|
||||||
|
{
|
||||||
|
return Base::retSuccess('success', [
|
||||||
|
'need' => Base::settingFind('system', 'reg') == 'invite'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/users/info 05. 获取我的信息
|
* @api {get} api/users/info 05. 获取我的信息
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,13 @@
|
|||||||
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />
|
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />
|
||||||
|
|
||||||
<Input v-if="loginType=='reg'" v-model="password2" prefix="ios-lock-outline" :placeholder="$L('输入确认密码')" type="password" size="large" @on-enter="onLogin" />
|
<Input v-if="loginType=='reg'" v-model="password2" prefix="ios-lock-outline" :placeholder="$L('输入确认密码')" type="password" size="large" @on-enter="onLogin" />
|
||||||
|
<Input v-if="loginType=='reg' && regNeedInvite" v-model="invite" class="login-code" :placeholder="$L('请输入注册邀请码')" type="text" size="large" @on-enter="onLogin"><span slot="prepend"> {{$L('邀请码')}} </span></Input>
|
||||||
|
|
||||||
<Input v-if="codeNeed" v-model="code" class="login-code" :placeholder="$L('输入图形验证码')" size="large" @on-enter="onLogin">
|
<Input v-if="loginType=='login' && codeNeed" v-model="code" class="login-code" :placeholder="$L('输入图形验证码')" size="large" @on-enter="onLogin">
|
||||||
<Icon type="ios-checkmark-circle-outline" class="login-icon" slot="prepend"></Icon>
|
<Icon type="ios-checkmark-circle-outline" class="login-icon" slot="prepend"></Icon>
|
||||||
<div slot="append" class="login-code-end" @click="reCode"><img :src="codeUrl"/></div>
|
<div slot="append" class="login-code-end" @click="reCode"><img :src="codeUrl"/></div>
|
||||||
</Input>
|
</Input>
|
||||||
|
|
||||||
<Button type="primary" :loading="loadIng > 0 || loginJump" size="large" long @click="onLogin">{{$L(loginText)}}</Button>
|
<Button type="primary" :loading="loadIng > 0 || loginJump" size="large" long @click="onLogin">{{$L(loginText)}}</Button>
|
||||||
|
|
||||||
<div v-if="loginType=='reg'" class="login-switch">{{$L('已经有帐号?')}}<a href="javascript:void(0)" @click="loginType='login'">{{$L('登录帐号')}}</a></div>
|
<div v-if="loginType=='reg'" class="login-switch">{{$L('已经有帐号?')}}<a href="javascript:void(0)" @click="loginType='login'">{{$L('登录帐号')}}</a></div>
|
||||||
@ -64,8 +66,11 @@ export default {
|
|||||||
password: '',
|
password: '',
|
||||||
password2: '',
|
password2: '',
|
||||||
code: '',
|
code: '',
|
||||||
|
invite: '',
|
||||||
|
|
||||||
demoAccount: {},
|
demoAccount: {},
|
||||||
|
|
||||||
|
regNeedInvite: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -86,6 +91,13 @@ export default {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
loginType(val) {
|
||||||
|
if (val == 'reg') {
|
||||||
|
this.getNeedInvite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDemoAccount() {
|
getDemoAccount() {
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
@ -101,6 +113,16 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNeedInvite() {
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'users/reg/needinvite',
|
||||||
|
}).then(({data}) => {
|
||||||
|
this.regNeedInvite = !!data.need;
|
||||||
|
}).catch(() => {
|
||||||
|
this.regNeedInvite = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
forgotPassword() {
|
forgotPassword() {
|
||||||
$A.modalWarning("请联系管理员!");
|
$A.modalWarning("请联系管理员!");
|
||||||
},
|
},
|
||||||
@ -151,9 +173,13 @@ export default {
|
|||||||
email: this.email,
|
email: this.email,
|
||||||
password: this.password,
|
password: this.password,
|
||||||
code: this.code,
|
code: this.code,
|
||||||
|
invite: this.invite,
|
||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
|
this.password = "";
|
||||||
|
this.code = "";
|
||||||
|
this.invite = "";
|
||||||
this.$store.state.method.setStorage("cacheLoginEmail", this.email)
|
this.$store.state.method.setStorage("cacheLoginEmail", this.email)
|
||||||
this.$store.dispatch("handleClearCache", data).then(() => {
|
this.$store.dispatch("handleClearCache", data).then(() => {
|
||||||
this.goNext1();
|
this.goNext1();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user