GithubHelp home page GithubHelp logo

aleprog / ionic-auth-starter-with-laravel-passport Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ivanaquino/ionic-auth-starter-with-laravel-passport

0.0 2.0 0.0 1.61 MB

Ionic project using authentication with Laravel passport

TypeScript 9.46% HTML 20.07% CSS 2.97% JavaScript 0.62% PHP 66.41% Vue 0.47%

ionic-auth-starter-with-laravel-passport's Introduction

#Ionic Auth starter with Laravel Passport

Laravel setup

Run command

composer install
cp .env.example .env
php artisan key:generate

Configure your database in .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your-database-name
DB_USERNAME=homestead
DB_PASSWORD=secret

Run migrations

php artisan migrate

Install passport

php artisan passport:install

Ionic setup

Install node modules

npm install

Settings of passport client

Copy client credentials of passport from table oauth_clients usually is the second record

Client id 2 named Laravel Password Grant Client

Or create new client for ionic app and save Client ID and Client Secret

php artisan passport:client --password

Enter to file src/settings/Laravel.ts and modify json config, replace url and apiUrl with your project url and your passport client credentials

// this example is running with php artisan serve
export const Service: any = {

    url: 'http://127.0.0.1:800',
    apiUrl: 'http://127.0.0.1:800/api',

    passport: {
        'grant_type': 'password',
        'client_id': 'your-client-id',
        'client_secret': 'your-client-secret',
    }

};

Prevent enter to unauthorized pages

Import AuthProvider to your page

Example

import { AuthProvider } from '../../providers/auth/auth';

And add this function

async ionViewCanEnter () {
    let isAuthenticated = await this.authService.checkIsAuthenticated();
    return isAuthenticated;
}

Donations

Donate

ionic-auth-starter-with-laravel-passport's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.