github-current-user

2018-12-06 admin

github-current-user是什么

什么是github-current-user,Verify the current GitHub user via their private keys

github-current-user使用教程帮助文档

github-current-user

Get the current GitHub user and verify that they have access to a private key that’s been authorized to that account.

Uses the username in user.username or github.user or the email address in user.email of the user’s .gitconfig and the private keys in in the user’s ssh-agent with fallback to ~/.ssh/id_rsa or ~/.ssh/id_dsa.

If the username is known, you can use verifyUser and pass it as the first argument which bypasses .gitconfig lookup work.

examples

var user = require('github-current-user');

user.verify(function (err, verified, username) {
  // if verified === true, the user has the correct private key or ssh-agent
  // for the username in the `username`
  console.log(verified, username);
});
var user = require('github-current-user');

user.verifyUser('beaugunderson', function (err, verified, username) {
  // if verified === true, the user has the correct private key or ssh-agent
  // for the username in the `username`
  console.log(verified, username);
});

test out on the cli

$ npm i github-current-user -g
$ github-current-user
You are verified as maxogden

$ github-current-user maxogden
You are verified as maxogden

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-47461.html

文章标题:github-current-user

回到顶部