check that alias and pass are populated strings

This commit is contained in:
Daniel Lugo 2021-04-03 21:28:11 -04:00
parent a0d5824696
commit aaf4c6292f

View file

@ -1,6 +1,7 @@
/**
* @format
*/
const Common = require('shock-common')
const Gun = require('gun')
// @ts-ignore
require('gun/nts')
@ -308,6 +309,16 @@ const getUser = () => {
* @returns {Promise<string>}
*/
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 isFreshGun = _user !== user
if (isFreshGun) {