How to use the @lskjs/utils/canonizeUsername function in @lskjs/utils

To help you get started, we’ve selected a few @lskjs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lskjs / lskjs / packages / auth / src / server / Api / AuthApi.js View on Github external
getUserFields(req) {
    const params = req.allParams();
    // console.log({ params });
    if (params.login) {
      if (!params.username) {
        params.username = params.login;
      }
      if (!params.email && validateEmail(params.login)) {
        params.email = params.login;
      } // if email
    }
    if (params.username) params.username = canonizeUsername(params.username);
    if (params.email) params.email = canonize(params.email);
    // console.log({ params });
    return params;
  }
github lskjs / lskjs / packages / auth / src / server / controller / controller.js View on Github external
controller.getUserFields = function (req) {
    const params = req.allParams();
    // console.log({ params });
    if (params.login) {
      if (!params.username) {
        params.username = params.login;
      }
      if (!params.email && validateEmail(params.login)) {
        params.email = params.login;
      } // if email
    }
    if (params.username) params.username = canonizeUsername(params.username);
    if (params.email) params.email = canonize(params.email);
    // console.log({ params });
    return params;
  };
  controller.getUserCriteria = function (req) {
github lskjs / lskjs / packages / auth / src / server / models / PassportModel.js View on Github external
schema.methods.generateUsername = async function a(collection) {
    // const { User: UserModel } = ctx.models;
    let username = `${this.providerId}_${this.provider}`;
    username = canonizeUsername(username.toLowerCase());
    if (!collection) return username;
    if (!(await collection.count({ username }))) return username;
    const prefixusername = `${username}_`;

    // TODO!!!!!! убрать хуев китайский стайл цикл
    username = prefixusername + (Math.random() % 100);
    if (!(await collection.count({ username }))) return username;

    username = prefixusername + (Math.random() % 100);
    if (!(await collection.count({ username }))) return username;

    throw 'cant generate unique username';
  };
  schema.methods.getUser = async function a() {