https://github.com/replit/repl-auth-node
Nodejs client for Repl Auth functions!
https://github.com/replit/repl-auth-node
Last synced: 9 months ago
JSON representation
Nodejs client for Repl Auth functions!
- Host: GitHub
- URL: https://github.com/replit/repl-auth-node
- Owner: replit
- Created: 2022-08-09T23:33:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T20:44:30.000Z (over 2 years ago)
- Last Synced: 2025-02-17T12:45:37.156Z (12 months ago)
- Language: JavaScript
- Size: 75.2 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Repl Authentication
Repl Authentication is a simple way to allow users to log in, and access their information.
## Get started
Ensure that a user is logged in with replit following [our docs](https://docs.replit.com/hosting/authenticating-users-repl-auth)
```js
const express = require('express');
const { getUserInfo } = require('../index.js')
const app = express();
app.use(express.static('public'));
app.get('/', async function(req, res) {
const userInfo = getUserInfo(req)
console.log(userInfo)
}
```
## Docs
> `getUserInfo(Request req)`
Gets all user info. Returns UserInfo object.
```js
const userInfo = getUserInfo(req)
```
UserInfo object:
```
UserInfo {
id?: string;
name?: string;
bio?: string;
url?: string;
profileImage?: string;
roles?: Array
teams?: Array
}
```
## Tests
```sh
npm run test
```
Then login and assure that it says "server tests passed"