Skip to content

Commit

Permalink
return customer after register.
Browse files Browse the repository at this point in the history
  • Loading branch information
yushine committed Aug 1, 2024
1 parent 19d0926 commit beb8f31
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -19,6 +20,6 @@ public function register(): void
*/
public function boot(): void
{
//
Schema::defaultStringLength(255);
}
}
9 changes: 5 additions & 4 deletions innopacks/front/lang/en/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

return [
'register' => 'Register',
'register_text' => 'Please fill in the registration information in the form below',
'register_submit' => 'Register now',
'have_account' => 'Already have an account? log in',
'register' => 'Register',
'register_text' => 'Please fill in the registration information in the form below',
'register_submit' => 'Register now',
'have_account' => 'Already have an account? log in',
'register_success' => 'Register successfully.',
];
9 changes: 5 additions & 4 deletions innopacks/front/lang/es/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

return [
'register' => 'Registrarse',
'register_text' => 'Por favor, complete la información de registro en el formulario a continuación',
'register_submit' => 'Regístrate ahora',
'have_account' => '¿Ya tienes una cuenta? Inicia sesión',
'register' => 'Registrarse',
'register_text' => 'Por favor, complete la información de registro en el formulario a continuación',
'register_submit' => 'Regístrate ahora',
'have_account' => '¿Ya tienes una cuenta? Inicia sesión',
'register_success' => 'Register successfully.',
];
9 changes: 5 additions & 4 deletions innopacks/front/lang/zh_cn/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
*/

return [
'register' => '注册',
'register_text' => '请在下面表单中填写注册信息',
'register_submit' => '立即注册',
'have_account' => '已有账号?点击登录',
'register' => '注册',
'register_text' => '请在下面表单中填写注册信息',
'register_submit' => '立即注册',
'have_account' => '已有账号?点击登录',
'register_success' => '注册成功',
];
10 changes: 7 additions & 3 deletions innopacks/front/src/Controllers/Account/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
namespace InnoShop\Front\Controllers\Account;

use App\Http\Controllers\Controller;
use Exception;
use Illuminate\Http\JsonResponse;
use InnoShop\Common\Services\CartService;
use InnoShop\Front\Requests\RegisterRequest;
use InnoShop\Front\Services\AccountService;
use Throwable;

class RegisterController extends Controller
{
/**
* @return mixed
* @throws Exception
*/
public function index(): mixed
{
Expand All @@ -32,19 +35,20 @@ public function index(): mixed
/**
* @param RegisterRequest $request
* @return JsonResponse
* @throws Throwable
*/
public function store(RegisterRequest $request): JsonResponse
{
try {
$oldGuestId = current_guest_id();
$credentials = $request->only('email', 'password');
AccountService::getInstance()->register($credentials);
$customer = AccountService::getInstance()->register($credentials);
auth('customer')->attempt($credentials);

CartService::getInstance(current_customer_id())->mergeCart($oldGuestId);

return json_success('注册成功');
} catch (\Exception $e) {
return json_success(trans('front::register.register_success'), ['customer' => $customer]);
} catch (Exception $e) {
return json_fail($e->getMessage());
}
}
Expand Down

0 comments on commit beb8f31

Please sign in to comment.