{"id":24960275,"url":"https://github.com/sofyanboukir/backend-auth","last_synced_at":"2025-03-28T21:24:14.352Z","repository":{"id":274963826,"uuid":"924605038","full_name":"sofyanBoukir/Backend-Auth","owner":"sofyanBoukir","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-30T11:34:51.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T12:28:02.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sofyanBoukir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-30T10:22:17.000Z","updated_at":"2025-01-30T11:34:55.000Z","dependencies_parsed_at":"2025-01-30T12:39:26.769Z","dependency_job_id":null,"html_url":"https://github.com/sofyanBoukir/Backend-Auth","commit_stats":null,"previous_names":["sofyanboukir/backend-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofyanBoukir%2FBackend-Auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofyanBoukir%2FBackend-Auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofyanBoukir%2FBackend-Auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofyanBoukir%2FBackend-Auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofyanBoukir","download_url":"https://codeload.github.com/sofyanBoukir/Backend-Auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246101851,"owners_count":20723710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T08:07:37.780Z","updated_at":"2025-03-28T21:24:14.330Z","avatar_url":"https://github.com/sofyanBoukir.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authentication API\n\n## Overview\nThis API provides authentication-related endpoints for user login, verification, password reset, and logout.\n\n## Installation\n\n### Prerequisites\n- PHP 8+\n- Composer\n- Laravel Framework Installed\n- MySQL database\n\n### Setup\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/sofyanBoukir/Backend-Auth.git\n   cd Backend-Auth\n   ```\n2. Install dependencies:\n   ```sh\n   composer install\n   ```\n3. Copy the environment file and configure the database:\n   ```sh\n   cp .env.example .env\n   ```\n   Update `.env` with your database credentials IMPORTANT\n   \n5. Setup your smtp data IMPORTANT\n   ```sh\n    MAIL_MAILER=smtp\n    MAIL_HOST=smtp.gmail.com\n    MAIL_PORT=465 \n    MAIL_USERNAME=soufianeexample01@example.com\n    MAIL_PASSWORD=************\n    MAIL_FROM_ADDRESS=\"soufianeexample01@example.com\"\n    MAIL_FROM_NAME=\"SOFYAN\"\n   ```\n\n6. Setup your frontend (Example) on `.env`\n    ```\n    FRONTEND_URL=http://localhost:5173\n    ```\n\n7. Generate application key:\n   ```sh\n   php artisan key:generate\n   ```\n8. Run migrations:\n   ```sh\n   php artisan migrate\n   ```\n9. Install and configure JWT authentication:\n   ```sh\n   php artisan vendor:publish --provider=\"Tymon\\JWTAuth\\Providers\\LaravelServiceProvider\"\n   ```\n   Generate JWT secret key:\n   ```sh\n   php artisan jwt:secret\n   ```\n10. Start the development server:\n   ```sh\n   php artisan serve\n   ```\n\n## Base URL\n```\nhttp://localhost:8000/api/auth\n```\n\n## Endpoints\n\n### 1. User Login\n**Endpoint:**\n```\nPOST /auth/login\n```\n**Description:**\nAuthenticate a user using email and password.\n\n**Request Body:**\n```json\n{\n  \"email\": \"test@example.com\",\n  \"password\": \"password\"\n}\n```\n\n**Response:**\n```json\n{\n  \"token\" : \"token gived from server\",\n  \"userDara\": {\n            \"id\" : 1,\n            \"name\" : \"Test User\",\n            \"email\" : \"test@example.com\",\n            \"email_verified_at\" : \"2025-01-30T12:02:08.000000Z\",\n            \"created_at\" : \"2025-01-30T12:02:09.000000Z\",\n            \"updated_at\" : \"2025-01-30T12:02:09.000000Z\"\n        }\n}\n```\nOr:\n```json\n{\n    \"message\" : \"Email or password incorrect\"\n}\n```\n\n---\n\n### 2. Send Verification Code\n**Endpoint:**\n```\nPOST /auth/sendVerificationCode\n```\n**Description:**\nSends a verification code to the registered email.\n**Note!:**\nVerification code expires in 2 minutes, you can modify it on line 64 `now()-\u003eaddMinutes(2)`\n\n**Request Body:**\n```json\n{\n  \"email\": \"user@example.com\"\n}\n```\n\n**Response:**\n```json\n{\n  \"message\": \"Verification code sent successfully\"\n}\n```\nOR:\n```json\n{\n  \"message\": \"User with this email already exists\"\n}\n```\n\n---\n\n### 3. Verify Code\n**Endpoint:**\n```\nPOST /auth/verifyCode\n```\n**Description:**\nVerifies the code sent to the user's email.\n\n**Request Body:**\n```json\n{\n  \"email\" : \"user@example.com\",\n  \"code\" : \"123456\",\n  \"fullName\" : \"Sofyan bou\",\n  \"password\" : \"1234\"\n}\n```\n\n**Response:**\n\n```json\n{\n  \"message\": \"Successfully registred\"\n}\n```\nOr:\n```json\n{\n  \"message\": \"Verification code expired or incorrect!\"\n}\n```\n\n---\n\n### 4. Send Password Reset Link\n**Endpoint:**\n```\nPOST /auth/sendResetLink\n```\n**Description:**\nSends a password reset link to the provided email.\n\n**Request Body:**\n```json\n{\n  \"email\": \"user@example.com\"\n}\n```\n\n**Response:**\n```json\n{\n  \"message\": \"Your reset link has been sent to your email\"\n}\n```\nOr:\n```json\n{\n  \"message\": \"User with this email does not exist\"\n}\n```\n\n---\n\n### 5. Reset Password\n**Endpoint:**\n```\nPOST /auth/resetPassword\n```\n**Description:**\nResets the user's password using the provided token.\n\n**Request Body:**\n```json\n{\n  \"email\" : \"user@example.com from the URL\",\n  \"token\" : \"reset-token from the URL\",\n  \"password\" : \"12345\",\n  \"password_confirmation\" : \"12345\"\n}\n```\n\n**Response:**\n```json\n{\n  \"message\" : \"Password reseted successfully!\"\n}\n```\nOr:\n```json\n{\n  \"message\" : \"This password reset token is invalid.\"\n}\n```\n\n---\n\n### 6. Logout\n**Endpoint:**\n```\nPOST /auth/logout\n```\n**Description:**\nLogs out the authenticated user.\n\n**Request Headers:**\n```json\n{\n  \"Authorization\": \"Bearer {token}\"\n}\n```\n\n**Response:**\n```json\n{\n  \"message\": \"User logged out successfully\"\n}\n```\nOr:\n```json\n{\n  \"message\": \"Token Signature could not be verified.\"\n}\n```\n\n---\n\n## Authentication\n- Only logout route requires a valid JWT token.\n- Include the token in the `Authorization` header as `Bearer {token}`.\n\n## Notes\n- Configure your database credentianls on `.env` file.\n- Configure your smtp credentials on `.env` file.\n- Configure your frontend base-url on `.env` file.\n- Tokens expire after 60 mins a certain period; users must re-authenticate when needed.\n- Configure the token time to live in `config/jwt.php` on `104` line `minutes` if you want.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofyanboukir%2Fbackend-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofyanboukir%2Fbackend-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofyanboukir%2Fbackend-auth/lists"}