{"id":20143894,"url":"https://github.com/aghae/ejwt-nuxt2","last_synced_at":"2026-05-04T17:35:12.019Z","repository":{"id":57221185,"uuid":"453729281","full_name":"aghae/ejwt-nuxt2","owner":"aghae","description":"jwt for nuxt ","archived":false,"fork":false,"pushed_at":"2022-01-31T08:55:17.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-12T00:19:49.924Z","etag":null,"topics":["json","jwt","nuxt","security","token"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/aghae.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}},"created_at":"2022-01-30T16:09:49.000Z","updated_at":"2022-07-05T09:09:58.000Z","dependencies_parsed_at":"2022-08-29T01:50:44.713Z","dependency_job_id":null,"html_url":"https://github.com/aghae/ejwt-nuxt2","commit_stats":null,"previous_names":["aghae/ejwt-nuxt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aghae/ejwt-nuxt2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aghae%2Fejwt-nuxt2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aghae%2Fejwt-nuxt2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aghae%2Fejwt-nuxt2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aghae%2Fejwt-nuxt2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aghae","download_url":"https://codeload.github.com/aghae/ejwt-nuxt2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aghae%2Fejwt-nuxt2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32618052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json","jwt","nuxt","security","token"],"created_at":"2024-11-13T22:07:23.773Z","updated_at":"2026-05-04T17:35:11.984Z","avatar_url":"https://github.com/aghae.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Nuxt module  \nwrapper for [Express JWT Enhanced](https://www.npmjs.com/package/express-jwt-enhanced)\n\neasy json web token on nuxt\n\n### insall\n`  npm install ejwt-nuxt `\n\n### usage\nin nuxt.config :\n\n    modules : [\n        .\n        .\n\n        ['ejwt-nuxt',{\n\n            apiPath:'/auth',          //ejwt-nuxt module api's path that end user see\n\n            loginUrl:'/your/api/login',    //server callback for login\n            redirect:{\n                login  : '/afer/success/login',   //if not be set redirect to current route\n                logout : 'after/success/logout'   //if not be set redirect to current route\n            },\n\n            //enhanced express jwt default options :\n            // you can set none or some these\n             sec_cookie:true,\n             expire: 3600,           // alive for seconds\n             secret :`$eCr3T`,       // importat!!!! : change it\n             sec_cookie: false,      // if true only pass on https. on develop dont set it to true\n             use_redis : false,      // use redis or not\n             redis_host:'localhost',\n             redis_port:6379,\n             redis_pass:'',\n\n        }],\n\n    ]\n    \n\n### login callback :\nfor example  `/your/api/login` that has shown in above as `loginUrl` can be like this :`\n\n    const express = require('express)\n    app=express()\n\n    app.post(\"/login\",async (req,res)=\u003e{\n        var user=req.body.user,\n            pass=req.body.pass\n        \n        if(user=='aghae' \u0026\u0026 pass=='123'){\n            res.json({\n                        loggined:true,      //important : for authed user must be set\n                        //... extra data\n                   \n                    })\n        }\n        else\n            res.json({err:'Invalid username or password'})\n    })\n\n### api's\n\n* **loggined()** : check loggined or not ; return true or false\n\n* **login(user,pass,redirect='')** :call login callback \n        \n        \u003cbutton @click=\"$ejwt.login({user,pass})\"\u003elogin\u003c/button\u003e\n\n        \u003cbutton @click=\"$ejwt.login({user,pass},'path/to/redirect/url')\"\u003elogin\u003c/button\u003e\n\n* **logout(redirect='')**\n\n        \u003cbutton @click=\"$ejwt.logout()\"\u003elogout\u003c/button\u003e\n\n        \u003cbutton @click=\"$ejwt.logout('path/to/redirect/url')\"\u003elogout\u003c/button\u003e\n\n* **set(payload)**\n\n        \u003cbutton @click=\"$ejwt.set({profile:{name:'aghae'}})\"\u003eset\u003c/button\u003e\n    \n* **setkey(key,val,expire=0)** : expire in seconds.default is 0 means unlimited\n\n        \u003cbutton @click=\"$ejwt.setkey('profile.favs',['watch Movie','Read Book'],5)\"\u003esetkey\u003c/button\u003e\n\n* **unsetkey(key)**\n        \n        \u003cbutton @click=\"$ejwt.unsetkey('profile.favs')\"\u003eunsetkey\u003c/button\u003e\n        \n   \n* **get(key='')**  : if key not be set. it will return all payload \n       \n        //in template\n        {{$ejwt.get()}}   \n\n        //in methods    \n        var payload = this.$ejwt.get()\n\n* **fetch()**  :  fetch payload on refresh page:\n\n    *for ssr app  ,   in store/index.js :*\n\n        export const actions = {\n            .\n            .\n            async nuxtServerInit ({dispatch}) {\n                this.$ejwt.fetch()\n            } \n\n        }\n\n    \n    *for spa app in nuxt page :*\n\n        export default {\n            .\n            .  \n            async fetch() {\n                this.$ejwt.fetch()   \n            },\n        }\n\n\n* **captcha_get(type='math',name='captcha')**  //type= math or text\n\n        //in template :\n        \u003cdiv ref='captcha'\u003e\u003c/div\u003e\n\n        //in methods:\n        this.$refs.captcha.innerHTML = await this.$ejwt.captcha_gen('math','captcha_name')\n\n* **captcha_check(text,name='captcha')** \n\n        await this.$ejwt.captcha_chk(this.captcha_txt,'captcha_name')\n\n\n* **csrfgen()**  : generate csurf\n\n        await this.$ejwt.csrfgen()\n\n\n* **csrfchk()**  :check csurf\n    \n        var csrf_chk = await this.$ejwt.csrfchk()\n\n        if(csrf_chk.err) \n            console.log('csruf token error')\n        else\n            do somthing....\n\n\n\nFin.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghae%2Fejwt-nuxt2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faghae%2Fejwt-nuxt2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghae%2Fejwt-nuxt2/lists"}