lolizan

Untitled

Jun 1st, 2021
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Авторизация на бэке
  2.  
  3.  
  4. class LoginController extends Controller
  5. {
  6. public function authenticate(Request $request)
  7. {
  8.  
  9. $credentials = $request->only('name', 'password');
  10.  
  11. if (Auth::attempt($credentials)) {
  12. return ['status' => 'success'];
  13. }
  14.  
  15. return ['status' => 'error'];
  16. }
  17.  
  18.  
  19. Авторизация на фронте
  20.  
  21. export async function login(name: "admin" | String, password: "admin" | String) {
  22. const payload = await request("POST", "/auth", {
  23. name, password
  24. })
  25.  
  26. return handleError(payload)
  27. }
Add Comment
Please, Sign In to add comment