1
0

RemoteAuthController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\RemoteAuth;
  4. use App\Rules\PixelfedUsername;
  5. use App\Services\Account\RemoteAuthService;
  6. use App\Services\EmailService;
  7. use App\Services\MediaStorageService;
  8. use App\Services\SanitizeService;
  9. use App\User;
  10. use App\Util\ActivityPub\Helpers;
  11. use App\Util\Lexer\RestrictedNames;
  12. use Illuminate\Auth\Events\Registered;
  13. use Illuminate\Http\Request;
  14. use Illuminate\Support\Facades\Auth;
  15. use Illuminate\Support\Facades\Hash;
  16. use Illuminate\Support\Str;
  17. use InvalidArgumentException;
  18. use Purify;
  19. class RemoteAuthController extends Controller
  20. {
  21. public function start(Request $request)
  22. {
  23. abort_unless((
  24. config_cache('pixelfed.open_registration') &&
  25. config('remote-auth.mastodon.enabled')
  26. ) || (
  27. config('remote-auth.mastodon.ignore_closed_state') &&
  28. config('remote-auth.mastodon.enabled')
  29. ), 404);
  30. if ($request->user()) {
  31. return redirect('/');
  32. }
  33. return view('auth.remote.start');
  34. }
  35. public function startRedirect(Request $request)
  36. {
  37. return redirect('/login');
  38. }
  39. public function getAuthDomains(Request $request)
  40. {
  41. abort_unless((
  42. config_cache('pixelfed.open_registration') &&
  43. config('remote-auth.mastodon.enabled')
  44. ) || (
  45. config('remote-auth.mastodon.ignore_closed_state') &&
  46. config('remote-auth.mastodon.enabled')
  47. ), 404);
  48. if (config('remote-auth.mastodon.domains.only_custom')) {
  49. $res = config('remote-auth.mastodon.domains.custom');
  50. if (! $res || ! strlen($res)) {
  51. return [];
  52. }
  53. $res = explode(',', $res);
  54. return response()->json($res);
  55. }
  56. if (config('remote-auth.mastodon.domains.custom') &&
  57. ! config('remote-auth.mastodon.domains.only_default') &&
  58. strlen(config('remote-auth.mastodon.domains.custom')) > 3 &&
  59. strpos(config('remote-auth.mastodon.domains.custom'), '.') > -1
  60. ) {
  61. $res = config('remote-auth.mastodon.domains.custom');
  62. if (! $res || ! strlen($res)) {
  63. return [];
  64. }
  65. $res = explode(',', $res);
  66. return response()->json($res);
  67. }
  68. $res = config('remote-auth.mastodon.domains.default');
  69. $res = explode(',', $res);
  70. return response()->json($res);
  71. }
  72. public function redirect(Request $request)
  73. {
  74. abort_unless((
  75. config_cache('pixelfed.open_registration') &&
  76. config('remote-auth.mastodon.enabled')
  77. ) || (
  78. config('remote-auth.mastodon.ignore_closed_state') &&
  79. config('remote-auth.mastodon.enabled')
  80. ), 404);
  81. $this->validate($request, ['domain' => 'required']);
  82. $domain = $request->input('domain');
  83. if (str_starts_with(strtolower($domain), 'http')) {
  84. $res = [
  85. 'domain' => $domain,
  86. 'ready' => false,
  87. 'action' => 'incompatible_domain',
  88. ];
  89. return response()->json($res);
  90. }
  91. $validateInstance = Helpers::validateUrl('https://'.$domain.'/?block-check='.time());
  92. if (! $validateInstance) {
  93. $res = [
  94. 'domain' => $domain,
  95. 'ready' => false,
  96. 'action' => 'blocked_domain',
  97. ];
  98. return response()->json($res);
  99. }
  100. $compatible = RemoteAuthService::isDomainCompatible($domain);
  101. if (! $compatible) {
  102. $res = [
  103. 'domain' => $domain,
  104. 'ready' => false,
  105. 'action' => 'incompatible_domain',
  106. ];
  107. return response()->json($res);
  108. }
  109. if (config('remote-auth.mastodon.domains.only_default')) {
  110. $defaultDomains = explode(',', config('remote-auth.mastodon.domains.default'));
  111. if (! in_array($domain, $defaultDomains)) {
  112. $res = [
  113. 'domain' => $domain,
  114. 'ready' => false,
  115. 'action' => 'incompatible_domain',
  116. ];
  117. return response()->json($res);
  118. }
  119. }
  120. if (config('remote-auth.mastodon.domains.only_custom') && config('remote-auth.mastodon.domains.custom')) {
  121. $customDomains = explode(',', config('remote-auth.mastodon.domains.custom'));
  122. if (! in_array($domain, $customDomains)) {
  123. $res = [
  124. 'domain' => $domain,
  125. 'ready' => false,
  126. 'action' => 'incompatible_domain',
  127. ];
  128. return response()->json($res);
  129. }
  130. }
  131. $client = RemoteAuthService::getMastodonClient($domain);
  132. abort_unless($client, 422, 'Invalid mastodon client');
  133. $request->session()->put('state', $state = Str::random(40));
  134. $request->session()->put('oauth_domain', $domain);
  135. $query = http_build_query([
  136. 'client_id' => $client->client_id,
  137. 'redirect_uri' => $client->redirect_uri,
  138. 'response_type' => 'code',
  139. 'scope' => 'read',
  140. 'state' => $state,
  141. ]);
  142. $request->session()->put('oauth_redirect_to', 'https://'.$domain.'/oauth/authorize?'.$query);
  143. $dsh = Str::random(17);
  144. $res = [
  145. 'domain' => $domain,
  146. 'ready' => true,
  147. 'dsh' => $dsh,
  148. ];
  149. return response()->json($res);
  150. }
  151. public function preflight(Request $request)
  152. {
  153. abort_unless((
  154. config_cache('pixelfed.open_registration') &&
  155. config('remote-auth.mastodon.enabled')
  156. ) || (
  157. config('remote-auth.mastodon.ignore_closed_state') &&
  158. config('remote-auth.mastodon.enabled')
  159. ), 404);
  160. if (! $request->filled('d') || ! $request->filled('dsh') || ! $request->session()->exists('oauth_redirect_to')) {
  161. return redirect('/login');
  162. }
  163. return redirect()->away($request->session()->pull('oauth_redirect_to'));
  164. }
  165. public function handleCallback(Request $request)
  166. {
  167. abort_unless((
  168. config_cache('pixelfed.open_registration') &&
  169. config('remote-auth.mastodon.enabled')
  170. ) || (
  171. config('remote-auth.mastodon.ignore_closed_state') &&
  172. config('remote-auth.mastodon.enabled')
  173. ), 404);
  174. $domain = $request->session()->get('oauth_domain');
  175. if ($request->filled('code')) {
  176. $code = $request->input('code');
  177. $state = $request->session()->pull('state');
  178. throw_unless(
  179. strlen($state) > 0 && $state === $request->state,
  180. InvalidArgumentException::class,
  181. 'Invalid state value.'
  182. );
  183. $res = RemoteAuthService::getToken($domain, $code);
  184. if (! $res || ! isset($res['access_token'])) {
  185. $request->session()->regenerate();
  186. return redirect('/login');
  187. }
  188. $request->session()->put('oauth_remote_session_token', $res['access_token']);
  189. return redirect('/auth/mastodon/getting-started');
  190. }
  191. return redirect('/login');
  192. }
  193. public function onboarding(Request $request)
  194. {
  195. abort_unless((
  196. config_cache('pixelfed.open_registration') &&
  197. config('remote-auth.mastodon.enabled')
  198. ) || (
  199. config('remote-auth.mastodon.ignore_closed_state') &&
  200. config('remote-auth.mastodon.enabled')
  201. ), 404);
  202. if ($request->user()) {
  203. return redirect('/');
  204. }
  205. return view('auth.remote.onboarding');
  206. }
  207. public function sessionCheck(Request $request)
  208. {
  209. abort_unless((
  210. config_cache('pixelfed.open_registration') &&
  211. config('remote-auth.mastodon.enabled')
  212. ) || (
  213. config('remote-auth.mastodon.ignore_closed_state') &&
  214. config('remote-auth.mastodon.enabled')
  215. ), 404);
  216. abort_if($request->user(), 403);
  217. abort_unless($request->session()->exists('oauth_domain'), 403);
  218. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  219. $domain = $request->session()->get('oauth_domain');
  220. $token = $request->session()->get('oauth_remote_session_token');
  221. $res = RemoteAuthService::getVerifyCredentials($domain, $token);
  222. abort_if(! $res || ! isset($res['acct']), 403, 'Invalid credentials');
  223. $webfinger = strtolower('@'.$res['acct'].'@'.$domain);
  224. $request->session()->put('oauth_masto_webfinger', $webfinger);
  225. if (config('remote-auth.mastodon.max_uses.enabled')) {
  226. $limit = config('remote-auth.mastodon.max_uses.limit');
  227. $uses = RemoteAuthService::lookupWebfingerUses($webfinger);
  228. if ($uses >= $limit) {
  229. return response()->json([
  230. 'code' => 200,
  231. 'msg' => 'Success!',
  232. 'action' => 'max_uses_reached',
  233. ]);
  234. }
  235. }
  236. $exists = RemoteAuth::whereDomain($domain)->where('webfinger', $webfinger)->whereNotNull('user_id')->first();
  237. if ($exists && $exists->user_id) {
  238. return response()->json([
  239. 'code' => 200,
  240. 'msg' => 'Success!',
  241. 'action' => 'redirect_existing_user',
  242. ]);
  243. }
  244. return response()->json([
  245. 'code' => 200,
  246. 'msg' => 'Success!',
  247. 'action' => 'onboard',
  248. ]);
  249. }
  250. public function sessionGetMastodonData(Request $request)
  251. {
  252. abort_unless((
  253. config_cache('pixelfed.open_registration') &&
  254. config('remote-auth.mastodon.enabled')
  255. ) || (
  256. config('remote-auth.mastodon.ignore_closed_state') &&
  257. config('remote-auth.mastodon.enabled')
  258. ), 404);
  259. abort_if($request->user(), 403);
  260. abort_unless($request->session()->exists('oauth_domain'), 403);
  261. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  262. $domain = $request->session()->get('oauth_domain');
  263. $token = $request->session()->get('oauth_remote_session_token');
  264. $res = RemoteAuthService::getVerifyCredentials($domain, $token);
  265. $res['_webfinger'] = strtolower('@'.$res['acct'].'@'.$domain);
  266. $res['_domain'] = strtolower($domain);
  267. $request->session()->put('oauth_remasto_id', $res['id']);
  268. $ra = RemoteAuth::updateOrCreate([
  269. 'domain' => $domain,
  270. 'webfinger' => $res['_webfinger'],
  271. ], [
  272. 'software' => 'mastodon',
  273. 'ip_address' => $request->ip(),
  274. 'bearer_token' => $token,
  275. 'verify_credentials' => $res,
  276. 'last_verify_credentials_at' => now(),
  277. 'last_successful_login_at' => now(),
  278. ]);
  279. $request->session()->put('oauth_masto_raid', $ra->id);
  280. return response()->json($res);
  281. }
  282. public function sessionValidateUsername(Request $request)
  283. {
  284. abort_unless((
  285. config_cache('pixelfed.open_registration') &&
  286. config('remote-auth.mastodon.enabled')
  287. ) || (
  288. config('remote-auth.mastodon.ignore_closed_state') &&
  289. config('remote-auth.mastodon.enabled')
  290. ), 404);
  291. abort_if($request->user(), 403);
  292. abort_unless($request->session()->exists('oauth_domain'), 403);
  293. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  294. $this->validate($request, [
  295. 'username' => [
  296. 'required',
  297. 'min:2',
  298. 'max:30',
  299. new PixelfedUsername,
  300. ],
  301. ]);
  302. $username = strtolower($request->input('username'));
  303. $exists = User::where('username', $username)->exists();
  304. return response()->json([
  305. 'code' => 200,
  306. 'username' => $username,
  307. 'exists' => $exists,
  308. ]);
  309. }
  310. public function sessionValidateEmail(Request $request)
  311. {
  312. abort_unless((
  313. config_cache('pixelfed.open_registration') &&
  314. config('remote-auth.mastodon.enabled')
  315. ) || (
  316. config('remote-auth.mastodon.ignore_closed_state') &&
  317. config('remote-auth.mastodon.enabled')
  318. ), 404);
  319. abort_if($request->user(), 403);
  320. abort_unless($request->session()->exists('oauth_domain'), 403);
  321. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  322. $this->validate($request, [
  323. 'email' => [
  324. 'required',
  325. 'email:strict,filter_unicode,dns,spoof',
  326. ],
  327. ]);
  328. $email = $request->input('email');
  329. $banned = EmailService::isBanned($email);
  330. $exists = User::where('email', $email)->exists();
  331. return response()->json([
  332. 'code' => 200,
  333. 'email' => $email,
  334. 'exists' => $exists,
  335. 'banned' => $banned,
  336. ]);
  337. }
  338. public function sessionGetMastodonFollowers(Request $request)
  339. {
  340. abort_unless((
  341. config_cache('pixelfed.open_registration') &&
  342. config('remote-auth.mastodon.enabled')
  343. ) || (
  344. config('remote-auth.mastodon.ignore_closed_state') &&
  345. config('remote-auth.mastodon.enabled')
  346. ), 404);
  347. abort_unless($request->session()->exists('oauth_domain'), 403);
  348. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  349. abort_unless($request->session()->exists('oauth_remasto_id'), 403);
  350. $domain = $request->session()->get('oauth_domain');
  351. $token = $request->session()->get('oauth_remote_session_token');
  352. $id = $request->session()->get('oauth_remasto_id');
  353. $res = RemoteAuthService::getFollowing($domain, $token, $id);
  354. if (! $res) {
  355. return response()->json([
  356. 'code' => 200,
  357. 'following' => [],
  358. ]);
  359. }
  360. $res = collect($res)->filter(fn ($acct) => Helpers::validateUrl($acct['url']))->values()->toArray();
  361. return response()->json([
  362. 'code' => 200,
  363. 'following' => $res,
  364. ]);
  365. }
  366. public function handleSubmit(Request $request)
  367. {
  368. abort_unless((
  369. config_cache('pixelfed.open_registration') &&
  370. config('remote-auth.mastodon.enabled')
  371. ) || (
  372. config('remote-auth.mastodon.ignore_closed_state') &&
  373. config('remote-auth.mastodon.enabled')
  374. ), 404);
  375. abort_unless($request->session()->exists('oauth_domain'), 403);
  376. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  377. abort_unless($request->session()->exists('oauth_remasto_id'), 403);
  378. abort_unless($request->session()->exists('oauth_masto_webfinger'), 403);
  379. abort_unless($request->session()->exists('oauth_masto_raid'), 403);
  380. $this->validate($request, [
  381. 'email' => 'required|email:strict,filter_unicode,dns,spoof',
  382. 'username' => [
  383. 'required',
  384. 'min:2',
  385. 'max:30',
  386. 'unique:users,username',
  387. function ($attribute, $value, $fail) {
  388. $dash = substr_count($value, '-');
  389. $underscore = substr_count($value, '_');
  390. $period = substr_count($value, '.');
  391. if (ends_with($value, ['.php', '.js', '.css'])) {
  392. return $fail('Username is invalid.');
  393. }
  394. if (($dash + $underscore + $period) > 1) {
  395. return $fail('Username is invalid. Can only contain one dash (-), period (.) or underscore (_).');
  396. }
  397. if (! ctype_alnum($value[0])) {
  398. return $fail('Username is invalid. Must start with a letter or number.');
  399. }
  400. if (! ctype_alnum($value[strlen($value) - 1])) {
  401. return $fail('Username is invalid. Must end with a letter or number.');
  402. }
  403. $val = str_replace(['_', '.', '-'], '', $value);
  404. if (! ctype_alnum($val)) {
  405. return $fail('Username is invalid. Username must be alpha-numeric and may contain dashes (-), periods (.) and underscores (_).');
  406. }
  407. $restricted = RestrictedNames::get();
  408. if (in_array(strtolower($value), array_map('strtolower', $restricted))) {
  409. return $fail('Username cannot be used.');
  410. }
  411. },
  412. ],
  413. 'password' => 'required|string|min:8|confirmed',
  414. 'name' => 'nullable|max:30',
  415. ]);
  416. $email = $request->input('email');
  417. $username = $request->input('username');
  418. $password = $request->input('password');
  419. $name = $request->input('name');
  420. $user = $this->createUser([
  421. 'name' => $name,
  422. 'username' => $username,
  423. 'password' => $password,
  424. 'email' => $email,
  425. ]);
  426. $raid = $request->session()->pull('oauth_masto_raid');
  427. $webfinger = $request->session()->pull('oauth_masto_webfinger');
  428. $token = $user->createToken('Onboarding')->accessToken;
  429. $ra = RemoteAuth::where('id', $raid)->where('webfinger', $webfinger)->firstOrFail();
  430. $ra->user_id = $user->id;
  431. $ra->save();
  432. return [
  433. 'code' => 200,
  434. 'msg' => 'Success',
  435. 'token' => $token,
  436. ];
  437. }
  438. public function storeBio(Request $request)
  439. {
  440. abort_unless((
  441. config_cache('pixelfed.open_registration') &&
  442. config('remote-auth.mastodon.enabled')
  443. ) || (
  444. config('remote-auth.mastodon.ignore_closed_state') &&
  445. config('remote-auth.mastodon.enabled')
  446. ), 404);
  447. abort_unless($request->user(), 404);
  448. abort_unless($request->session()->exists('oauth_domain'), 403);
  449. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  450. abort_unless($request->session()->exists('oauth_remasto_id'), 403);
  451. $this->validate($request, [
  452. 'bio' => 'required|nullable|max:500',
  453. ]);
  454. $profile = $request->user()->profile;
  455. $profile->bio = app(SanitizeService::class)->html($request->input('bio'));
  456. $profile->save();
  457. return [200];
  458. }
  459. public function accountToId(Request $request)
  460. {
  461. abort_unless((
  462. config_cache('pixelfed.open_registration') &&
  463. config('remote-auth.mastodon.enabled')
  464. ) || (
  465. config('remote-auth.mastodon.ignore_closed_state') &&
  466. config('remote-auth.mastodon.enabled')
  467. ), 404);
  468. abort_if($request->user(), 404);
  469. abort_unless($request->session()->exists('oauth_domain'), 403);
  470. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  471. abort_unless($request->session()->exists('oauth_remasto_id'), 403);
  472. $this->validate($request, [
  473. 'account' => 'required|url',
  474. ]);
  475. $account = $request->input('account');
  476. abort_unless(substr(strtolower($account), 0, 8) === 'https://', 404);
  477. $host = strtolower(config('pixelfed.domain.app'));
  478. $domain = strtolower(parse_url($account, PHP_URL_HOST));
  479. if ($domain == $host) {
  480. $username = Str::of($account)->explode('/')->last();
  481. $user = User::where('username', $username)->first();
  482. if ($user) {
  483. return ['id' => (string) $user->profile_id];
  484. } else {
  485. return [];
  486. }
  487. } else {
  488. try {
  489. $profile = Helpers::profileFetch($account);
  490. if ($profile) {
  491. return ['id' => (string) $profile->id];
  492. } else {
  493. return [];
  494. }
  495. } catch (\GuzzleHttp\Exception\RequestException $e) {
  496. return;
  497. } catch (Exception $e) {
  498. return [];
  499. }
  500. }
  501. }
  502. public function storeAvatar(Request $request)
  503. {
  504. abort_unless((
  505. config_cache('pixelfed.open_registration') &&
  506. config('remote-auth.mastodon.enabled')
  507. ) || (
  508. config('remote-auth.mastodon.ignore_closed_state') &&
  509. config('remote-auth.mastodon.enabled')
  510. ), 404);
  511. abort_unless($request->user(), 404);
  512. $this->validate($request, [
  513. 'avatar_url' => 'required|active_url',
  514. ]);
  515. $user = $request->user();
  516. $profile = $user->profile;
  517. abort_if(! $profile->avatar, 404, 'Missing avatar');
  518. $avatar = $profile->avatar;
  519. $avatar->remote_url = $request->input('avatar_url');
  520. $avatar->save();
  521. MediaStorageService::avatar($avatar, (bool) config_cache('pixelfed.cloud_storage') == false);
  522. return [200];
  523. }
  524. public function finishUp(Request $request)
  525. {
  526. abort_unless((
  527. config_cache('pixelfed.open_registration') &&
  528. config('remote-auth.mastodon.enabled')
  529. ) || (
  530. config('remote-auth.mastodon.ignore_closed_state') &&
  531. config('remote-auth.mastodon.enabled')
  532. ), 404);
  533. abort_unless($request->user(), 404);
  534. $currentWebfinger = '@'.$request->user()->username.'@'.config('pixelfed.domain.app');
  535. $ra = RemoteAuth::where('user_id', $request->user()->id)->firstOrFail();
  536. RemoteAuthService::submitToBeagle(
  537. $ra->webfinger,
  538. $ra->verify_credentials['url'],
  539. $currentWebfinger,
  540. $request->user()->url()
  541. );
  542. return [200];
  543. }
  544. public function handleLogin(Request $request)
  545. {
  546. abort_unless((
  547. config_cache('pixelfed.open_registration') &&
  548. config('remote-auth.mastodon.enabled')
  549. ) || (
  550. config('remote-auth.mastodon.ignore_closed_state') &&
  551. config('remote-auth.mastodon.enabled')
  552. ), 404);
  553. abort_if($request->user(), 404);
  554. abort_unless($request->session()->exists('oauth_domain'), 403);
  555. abort_unless($request->session()->exists('oauth_remote_session_token'), 403);
  556. abort_unless($request->session()->exists('oauth_masto_webfinger'), 403);
  557. $domain = $request->session()->get('oauth_domain');
  558. $wf = $request->session()->get('oauth_masto_webfinger');
  559. $ra = RemoteAuth::where('webfinger', $wf)->where('domain', $domain)->whereNotNull('user_id')->firstOrFail();
  560. $user = User::findOrFail($ra->user_id);
  561. abort_if($user->is_admin || $user->status != null, 422, 'Invalid auth action');
  562. Auth::loginUsingId($ra->user_id);
  563. return [200];
  564. }
  565. protected function createUser($data)
  566. {
  567. event(new Registered($user = User::create([
  568. 'name' => Purify::clean($data['name']),
  569. 'username' => $data['username'],
  570. 'email' => $data['email'],
  571. 'password' => Hash::make($data['password']),
  572. 'email_verified_at' => config('remote-auth.mastodon.contraints.skip_email_verification') ? now() : null,
  573. 'app_register_ip' => request()->ip(),
  574. 'register_source' => 'mastodon',
  575. ])));
  576. $this->guarder()->login($user);
  577. return $user;
  578. }
  579. protected function guarder()
  580. {
  581. return Auth::guard();
  582. }
  583. }