Migrate fbEmployee
Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D16827958 fbshipit-source-id: f2ab616b2682ede7da6c1e401fcc6d0644a1b960
This commit is contained in:
committed by
Facebook Github Bot
parent
2fac83420b
commit
03d4a7d750
25
src/utils/fbEmployee.tsx
Normal file
25
src/utils/fbEmployee.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright 2019-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
import util from 'util';
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
const cmd = 'klist --json';
|
||||
const endWith = '@THEFACEBOOK.COM';
|
||||
|
||||
export async function isFBEmployee(): Promise<boolean> {
|
||||
return exec(cmd).then(
|
||||
(stdobj: {stderr: string; stdout: string}) => {
|
||||
const principal = String(JSON.parse(stdobj.stdout).principal);
|
||||
|
||||
return principal.endsWith(endWith);
|
||||
},
|
||||
(_err: Error) => {
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user