-
-
Save rafbgarcia/0af25d0b1d784665576047f62332f47e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core' | |
import { Storage } from '@ionic/storage' | |
@Injectable() | |
export default class Motoboy { | |
constructor( | |
public storage: Storage | |
) {} | |
current() { | |
return this.storage.get("motoboy").then(motoboy => motoboy || {}) | |
} | |
isLoggedIn(motoboy):boolean { | |
return motoboy && motoboy.token | |
} | |
async set(changes = {}) { | |
const motoboy = await this.current() | |
await this.storage.set("motoboy", {...motoboy, ...changes}) | |
} | |
logout() { | |
this.storage.remove("motoboy") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment