check that alias and pass are populated strings
This commit is contained in:
parent
a0d5824696
commit
aaf4c6292f
1 changed files with 11 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
const Common = require('shock-common')
|
||||||
const Gun = require('gun')
|
const Gun = require('gun')
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
require('gun/nts')
|
require('gun/nts')
|
||||||
|
|
@ -308,6 +309,16 @@ const getUser = () => {
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
const authenticate = async (alias, pass, __user) => {
|
const authenticate = async (alias, pass, __user) => {
|
||||||
|
if (!Common.isPopulatedString(alias)) {
|
||||||
|
throw new TypeError(
|
||||||
|
`Expected alias to be a populated string, instead got: ${alias}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!Common.isPopulatedString(pass)) {
|
||||||
|
throw new TypeError(
|
||||||
|
`Expected pass to be a populated string, instead got: ${pass}`
|
||||||
|
)
|
||||||
|
}
|
||||||
const _user = __user || user
|
const _user = __user || user
|
||||||
const isFreshGun = _user !== user
|
const isFreshGun = _user !== user
|
||||||
if (isFreshGun) {
|
if (isFreshGun) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue