Commit 78039aee by 庄钊鑫

完整注册模块登录模块

parent 5b1320a3
......@@ -2,14 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="91f66d3c-41ac-41b6-86c7-896c6cbc8e56" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/controller/v1/app/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/controller/v1/app/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/model/Sms.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/model/Sms.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/model/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/model/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/model/UserToken.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/model/Token.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/common/validate/Base.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/common/validate/Base.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/route.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/route.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/runtime/log/201903/11.log" beforeDir="false" afterPath="$PROJECT_DIR$/runtime/log/201903/11.log" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -17,16 +15,16 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<component name="ComposerSettings" doNotAsk="true" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="517">
<caret line="219" column="48" selection-start-line="219" selection-start-column="48" selection-end-line="219" selection-end-column="48" />
<state relative-caret-position="288">
<caret line="101" column="41" selection-start-line="101" selection-start-column="41" selection-end-line="101" selection-end-column="41" />
<folding>
<element signature="e#45#72#0#PHP" expanded="true" />
</folding>
......@@ -35,58 +33,61 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<entry file="jar://$APPLICATION_HOME_DIR$/plugins/php/lib/php.jar!/stubs/session/session.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="347">
<caret line="102" column="5" lean-forward="true" selection-start-line="102" selection-start-column="5" selection-end-line="102" selection-end-column="5" />
<state relative-caret-position="268">
<caret line="82" column="9" selection-start-line="82" selection-start-column="9" selection-end-line="82" selection-end-column="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/common/validate/Validate.php">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="342">
<caret line="40" column="35" lean-forward="true" selection-start-line="40" selection-start-column="35" selection-end-line="40" selection-end-column="35" />
<state relative-caret-position="361">
<caret line="25" column="23" selection-start-line="25" selection-start-column="23" selection-end-line="25" selection-end-column="23" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/logic/app/UserLogic.php">
<entry file="file://$PROJECT_DIR$/thinkphp/library/think/Cache.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="261">
<caret line="30" column="27" selection-start-line="30" selection-start-column="27" selection-end-line="30" selection-end-column="27" />
<state relative-caret-position="375">
<caret line="190" selection-start-line="190" selection-end-line="190" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/logic/app/SendLogic.php">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="494">
<caret line="31" column="34" selection-start-line="31" selection-start-column="34" selection-end-line="31" selection-end-column="34" />
<state relative-caret-position="512">
<caret line="58" column="25" selection-start-line="58" selection-start-column="25" selection-end-line="58" selection-end-column="25" />
<folding>
<element signature="e#118#131#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/model/Sms.php">
<entry file="file://$PROJECT_DIR$/app/api/model/Token.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="111" column="27" selection-start-line="111" selection-start-column="27" selection-end-line="111" selection-end-column="27" />
<state relative-caret-position="691">
<caret line="108" column="45" selection-start-line="108" selection-start-column="45" selection-end-line="108" selection-end-column="45" />
<folding>
<element signature="e#33#49#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Send.php">
<entry file="file://$PROJECT_DIR$/app/common.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="417">
<caret line="83" column="44" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="44" />
<folding>
<element signature="e#132#158#0#PHP" expanded="true" />
</folding>
<state relative-caret-position="261">
<caret line="127" column="9" selection-start-line="127" selection-start-column="9" selection-end-line="127" selection-end-column="9" />
</state>
</provider>
</entry>
......@@ -94,26 +95,29 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/controller/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="579">
<caret line="84" column="24" selection-start-line="84" selection-start-column="13" selection-end-line="84" selection-end-column="24" />
<state relative-caret-position="212">
<caret line="154" column="83" selection-start-line="152" selection-start-column="16" selection-end-line="154" selection-end-column="83" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="328">
<caret line="90" column="42" selection-start-line="90" selection-start-column="42" selection-end-line="90" selection-end-column="42" />
<state relative-caret-position="637">
<caret line="96" column="34" selection-start-line="96" selection-start-column="34" selection-end-line="96" selection-end-column="34" />
<folding>
<element signature="e#132#158#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/route.php">
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="21" column="80" selection-start-line="21" selection-start-column="80" selection-end-line="21" selection-end-column="80" />
<state relative-caret-position="321">
<caret line="91" column="17" selection-start-line="91" selection-start-column="9" selection-end-line="91" selection-end-column="17" />
</state>
</provider>
</entry>
......@@ -127,9 +131,10 @@
<find>page_index</find>
<find>alidayu</find>
<find>getEnumRule</find>
<find>password</find>
<find>sms_type</find>
<find>sendSms</find>
<find>sms_type</find>
<find>password</find>
<find>name</find>
</findStrings>
</component>
<component name="Git.Settings">
......@@ -141,11 +146,14 @@
<option value="$PROJECT_DIR$/app/database.php" />
<option value="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" />
<option value="$PROJECT_DIR$/app/route.php" />
<option value="$PROJECT_DIR$/app/api/model/User.php" />
<option value="$PROJECT_DIR$/app/api/model/Sms.php" />
<option value="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" />
<option value="$PROJECT_DIR$/app/api/logic/app/SendLogic.php" />
<option value="$PROJECT_DIR$/app/api/model/UserToken.php" />
<option value="$PROJECT_DIR$/app/common/validate/Base.php" />
<option value="$PROJECT_DIR$/app/api/model/Token.php" />
<option value="$PROJECT_DIR$/app/api/controller/v1/app/User.php" />
<option value="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" />
<option value="$PROJECT_DIR$/app/api/model/User.php" />
</list>
</option>
</component>
......@@ -214,6 +222,13 @@
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="api" type="462c0819:PsiDirectoryNode" />
<item name="model" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="common" type="462c0819:PsiDirectoryNode" />
</path>
<path>
......@@ -223,6 +238,11 @@
<item name="common" type="462c0819:PsiDirectoryNode" />
<item name="validate" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="public" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
......@@ -257,25 +277,21 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1552287639374</updated>
<workItem from="1552287640754" duration="11594000" />
<workItem from="1552287640754" duration="12982000" />
<workItem from="1552352825843" duration="5264000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="11594000" />
<option name="totallyTimeSpent" value="18246000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19241774" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
......@@ -283,10 +299,15 @@
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Database" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" />
<window_info anchor="bottom" id="Version Control" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Database" order="3" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
......@@ -329,6 +350,27 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/UserLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="361">
<caret line="30" column="27" selection-start-line="30" selection-start-column="27" selection-end-line="30" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/SendLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="494">
<caret line="31" column="34" selection-start-line="31" selection-start-column="34" selection-end-line="31" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/Sms.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1995">
<caret line="111" column="27" selection-start-line="111" selection-start-column="27" selection-end-line="111" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/route.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
......@@ -336,74 +378,99 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<entry file="file://$PROJECT_DIR$/public/template.sql">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3345" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/common/validate/Validate.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="347">
<caret line="102" column="5" lean-forward="true" selection-start-line="102" selection-start-column="5" selection-end-line="102" selection-end-column="5" />
<state relative-caret-position="760">
<caret line="40" column="35" selection-start-line="40" selection-start-column="35" selection-end-line="40" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/Send.php">
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="579">
<caret line="84" column="24" selection-start-line="84" selection-start-column="13" selection-end-line="84" selection-end-column="24" />
<state relative-caret-position="321">
<caret line="91" column="17" selection-start-line="91" selection-start-column="9" selection-end-line="91" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/UserLogic.php">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="261">
<caret line="30" column="27" selection-start-line="30" selection-start-column="27" selection-end-line="30" selection-end-column="27" />
<state relative-caret-position="361">
<caret line="25" column="23" selection-start-line="25" selection-start-column="23" selection-end-line="25" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/Sms.php">
<entry file="jar://$APPLICATION_HOME_DIR$/plugins/php/lib/php.jar!/stubs/session/session.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="111" column="27" selection-start-line="111" selection-start-column="27" selection-end-line="111" selection-end-column="27" />
<state relative-caret-position="268">
<caret line="82" column="9" selection-start-line="82" selection-start-column="9" selection-end-line="82" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/SendLogic.php">
<entry file="file://$PROJECT_DIR$/app/common.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="494">
<caret line="31" column="34" selection-start-line="31" selection-start-column="34" selection-end-line="31" selection-end-column="34" />
<state relative-caret-position="261">
<caret line="127" column="9" selection-start-line="127" selection-start-column="9" selection-end-line="127" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/common/validate/Validate.php">
<entry file="file://$PROJECT_DIR$/thinkphp/library/think/Cache.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="342">
<caret line="40" column="35" lean-forward="true" selection-start-line="40" selection-start-column="35" selection-end-line="40" selection-end-column="35" />
<state relative-caret-position="375">
<caret line="190" selection-start-line="190" selection-end-line="190" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<entry file="file://$PROJECT_DIR$/app/api/controller/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="328">
<caret line="90" column="42" selection-start-line="90" selection-start-column="42" selection-end-line="90" selection-end-column="42" />
<state relative-caret-position="212">
<caret line="154" column="83" selection-start-line="152" selection-start-column="16" selection-end-line="154" selection-end-column="83" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="417">
<caret line="83" column="44" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="44" />
<state relative-caret-position="637">
<caret line="96" column="34" selection-start-line="96" selection-start-column="34" selection-end-line="96" selection-end-column="34" />
<folding>
<element signature="e#132#158#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/Token.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="691">
<caret line="108" column="45" selection-start-line="108" selection-start-column="45" selection-end-line="108" selection-end-column="45" />
<folding>
<element signature="e#33#49#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="517">
<caret line="219" column="48" selection-start-line="219" selection-start-column="48" selection-end-line="219" selection-end-column="48" />
<state relative-caret-position="288">
<caret line="101" column="41" selection-start-line="101" selection-start-column="41" selection-end-line="101" selection-end-column="41" />
<folding>
<element signature="e#45#72#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="512">
<caret line="58" column="25" selection-start-line="58" selection-start-column="25" selection-end-line="58" selection-end-column="25" />
<folding>
<element signature="e#118#131#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -93,6 +93,7 @@ class Send extends Base
if ($info === false) {
$this->returnmsg(403, [], [], "", [], "验证码错误");
}
$this->render(200,['success'=>'验证码正确']);
$success['success']['message'] = '验证码正确!';
$this->render(200,$success);
}
}
......@@ -3,12 +3,13 @@
namespace app\api\controller\v1\app;
use app\api\controller\Api;
use app\api\model\UserToken;
use app\api\model\Token;
use app\common\tools\wechatUtil;
use think\Db;
use app\api\logic\app\SendLogic;
use app\api\model\User as UserModel;
use app\api\logic\app\UserLogic;
use think\Cache;
/**
* 所有资源类接都必须继承基类控制器
......@@ -96,16 +97,11 @@ class User extends Base
*/
public function login()
{
$requestData = $this->selectParam(['mobile', 'code','oauth_uuid'=>""]);
$this->check($requestData, 'Base.login');
$requestData['sms_type'] = 'login';
$bool = SendLogic::validateCode($requestData);
if (!$bool) {
self::returnmsg(403, [], [], 'service_message', 'code error.', '验证码错误');
}
$result = UserModel::build()->login($requestData['mobile'],$requestData['oauth_uuid']);
$requestData = $this->selectParam(['mobile', 'password']);
$this->check($requestData, 'Base.cmsLogin');
$result = UserModel::build()->login($requestData);
if ($result) {
$this->render($result);
$this->render(200,$result);
} else {
$this->returnmsg(403, $data = [], $header = [], $type = "", "Login error", $message = "登录失败");
}
......@@ -166,9 +162,14 @@ class User extends Base
*/
public function validateMobile()
{
$requestData = $this->selectParam(['mobile','sms_type' => 'bind']);
$this->check($requestData, 'Base.sendSms');
$this->render(200,['success'=>'手机号码验证成功']);
$request = $this->selectParam(['mobile','sms_type' => 'bind']);
$this->check($request, 'Base.sendSms');
$bool = UserLogic::checkUser($request['mobile']);
if(!empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号已注册");
}
$success['success']['message'] = '手机号码验证成功';
$this->render(200,$success);
}
/**
......@@ -190,13 +191,18 @@ class User extends Base
$this->returnmsg(403, [], [],"", [], "该手机号已注册");
}
}
//$info = true;
$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
$this->returnmsg(403, [], [],"", [], "信息发送出现了一点小问题哟~");
$tokenId = md5(md5(time()));
Cache::set($tokenId,$request['mobile'],1800);
if(Cache::get($tokenId)){
$info = true;
//$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
$this->returnmsg(403, [], [],"", [], "信息发送出现了一点小问题哟~");
}
$success['success']['token'] = $tokenId;
$success['success']['message'] = '验证码发送成功';
$this->render(200,$success);
}
//发送成功
$this->render(200,['success'=>'验证码发送成功']);
}
/**
......@@ -209,15 +215,21 @@ class User extends Base
*/
public function register()
{
$request = $this->selectParam(['mobile', 'password','password2']);
$request = $this->selectParam(['mobile', 'password','password2','token']);
$this->check($request, 'Base.register');
$result = Token::validateToken2($request['token'],$request['mobile']);
if($result['status'] == 0){
$this->returnmsg(403, [], [],"", [], $result['message']);
}
$bool = UserLogic::checkUser($request['mobile']);
if(!empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号已注册");
}
$result = UserModel::build()->register($request);
if ($result) {
$this->render(200,['success'=>'注册成功!']);
Cache::rm($request['token']);
$success['success']['message'] = '注册成功!';
$this->render(200,$success);
} else {
$this->returnmsg(403, $data = [], $header = [], $type = "", "Login error", $message = "注册失败");
}
......
......@@ -3,16 +3,16 @@
namespace app\api\model;
use think\Model;
use think\Cache;
/**
* TOKEN
*/
class UserToken extends Model
class Token extends Model
{
/**
* 表名
*/
protected $table = 'user_token';
protected $table = 'token';
protected $dateFormat = false;
/**
......@@ -55,6 +55,30 @@ class UserToken extends Model
}
/**
* @author:
* @time: 2019年3月
* description
* @param $token
* @return array|bool|false|\PDOStatement|string|Model
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function validateToken2($tokenId,$mobile)
{
$getMobile = Cache::get($tokenId);
if($getMobile){
if($getMobile == $mobile){
return ['status' => 1];
}else{
return ['status' => 0,'message' => '手机号码不一致!'];
}
}
return ['status' => 0,'message' => 'token已失效!'];
}
/**
* @author: Airon
* @time: 2018年5月
* description
......
......@@ -37,55 +37,32 @@ class User extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login($mobile,$oauth_uuid)
public function login($requestData)
{
$user = self::build()->where(['mobile' => $mobile])
->field(['nickname','is_deleted','ban_time'],true)->find();
$user = self::build()->where(['mobile' => $requestData['mobile'],'password' => md5(md5($requestData['password']))])
->field(['password'],true)->find();
Db::startTrans();
if ($user) {
if ($user['is_banned']) {
ResponseDirect('当前账号已被禁用',403);
}
if(!empty($oauth_uuid)){
$oauth= UserOauth::build()->where(['uuid'=>$oauth_uuid])->find();
if(!empty($oauth)){
UserOauth::build()->where(['user_uuid'=>$user['uuid']])->update(['user_uuid'=>""]);
UserOauth::build()->where(['uuid'=>$oauth_uuid])->update(['user_uuid'=>$user['uuid']]);
}
}
$token = UserToken::storeToken($user['uuid']);
} else {
//创建新用户
$user['uuid'] = uuid();
$user['mobile'] = $mobile;
$user['name'] = replaceToStar($mobile);
$user['create_time'] = timeToDate(time());
// $user['invite_code'] = $this->get_unique_invite_code();
$result = self::build()->insert($user);
if ($result) {
//创建token
$token = UserToken::storeToken($user['uuid']);
if(!empty($oauth_uuid)){
$oauth= UserOauth::build()->where(['uuid'=>$oauth_uuid])->find();
if(!empty($oauth)){
UserOauth::build()->where(['uuid'=>$oauth_uuid])->update(['user_uuid'=>$user['uuid']]);
}
}
} else {
Db::rollback();
return false;
}
// if ($user['is_banned']) {
// ResponseDirect('当前账号已被禁用',403);
// }
// if(!empty($oauth_uuid)){
// $oauth= UserOauth::build()->where(['uuid'=>$oauth_uuid])->find();
// if(!empty($oauth)){
// UserOauth::build()->where(['user_uuid'=>$user['uuid']])->update(['user_uuid'=>""]);
// UserOauth::build()->where(['uuid'=>$oauth_uuid])->update(['user_uuid'=>$user['uuid']]);
//
// }
// }
$token = Token::storeToken($user['uuid']);
}else{
return false;
}
Db::commit();
$users['token'] = $token;
$users['user_info'] = self::build()
->where(['mobile'=>$mobile])
->field(['nickname','is_deleted','ban_time'],true)
->where(['mobile' => $requestData['mobile'],'password' => md5(md5($requestData['password']))])
->field(['name'],false)
->find();
return $users;
......@@ -107,6 +84,7 @@ class User extends Model
$user['mobile'] = $request['mobile'];
$user['name'] = replaceToStar($request['mobile']);
$user['create_time'] = timeToDate(time());
$user['password'] = md5(md5($request['password']));
$result = self::build()->insert($user);
if (!$result) {
Db::rollback();
......@@ -117,4 +95,6 @@ class User extends Model
return true;
}
}
\ No newline at end of file
......@@ -23,8 +23,8 @@ class Base extends Validate
'sms_type' => 'require|in:login,bind,pay_password,pass',
'partner_sms_type' => 'require|in:pass,set_pay,bind_card',
'code' => 'require|max:6',
'password' => 'require|min:6|confirm:password2',
'password2' => 'require',
'password' => 'require|min:6',
'password2' => 'require|confirm:password',
'message_type' => 'require|in:con,chat,system',
'province' => 'chsAlpha',
'school_name' => 'chsAlpha',
......@@ -38,7 +38,7 @@ class Base extends Validate
'keyword' => 'chsDash',
'refresh_token' => 'require|length:32',
'collect_type' => 'require|in:school,speciality',
'token' => 'require',
'name' => 'require|chsAlphaNum|length:0,64',
'gender' => 'require|in:男,女',
'birth' => 'require|chsAlphaNum|length:0,64',
......@@ -62,7 +62,8 @@ class Base extends Validate
'code' => '验证码格式错误',
'password.require' => '密码必须',
'password.min' => '密码过短',
'password.confirm' => '两次密码输入不一致',
'password2.confirm' => '两次密码输入不一致',
'token.require' => 'token必须',
'message_type' => '消息类型错误',
'province' => '省份设置错误',
'city.json' => '城市设置错误',
......@@ -88,7 +89,7 @@ class Base extends Validate
'id' => ['id'],
'uuid' => ['uuid'],
'sendSms' => ['mobile', 'sms_type'],
'register' => ['mobile','password','password2'],
'register' => ['mobile','password','password2','token'],
'sendPartnerSms' => ['mobile', 'sms_type_partner'],
'validatePartnerCode' => ['mobile', 'sms_type_partner', 'code'],
......@@ -103,7 +104,7 @@ class Base extends Validate
'refresh_token' => ['refresh_token'],
'feedback' => ['content'],
'collect_list' => ['collect_type'],
'cmsLogin' => ['name', 'password'],
'cmsLogin' => ['mobile', 'password'],
'admissionScore' => ['province','school_name'],
'batchCritical' => ['province']
......
<?php
//000000001800
exit();?>
s:11:"13302516724";
\ No newline at end of file
<?php
//000000001800
exit();?>
s:32:"1d6874d9fa1c1288e3cf7ed27fca63d2";
\ No newline at end of file
<?php
//000000001800
exit();?>
s:11:"13302516724";
\ No newline at end of file
<?php
//000000001800
exit();?>
s:32:"062a1c9363e70287295731c632e8efba";
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment