Skip to content

Commit

Permalink
Keep old names
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Jul 26, 2023
1 parent dc8641a commit 10e15da
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Accounts.emailTemplates.enrollAccount.html = function (user = {} /* , url*/) {

Accounts.insertUserDoc = function (...args) {
// Depends on meteor support for Async
return Promise.await(User.create(...args));
return Promise.await(User.insertUserDoc(...args));
};

const validateLoginAttemptAsync = async function (login) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/cas/server/cas_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Accounts.registerLoginHandler('cas', async function (options) {

// Create the user
logger.debug(`User "${result.username}" does not exist yet, creating it`);
const userId = await User.create({ globalRoles: ['user'] }, newUser);
const userId = await User.insertUserDoc({ globalRoles: ['user'] }, newUser);

// Fetch and use it
user = await Users.findOneById(userId);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/crowd/server/crowd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class CROWD {

// Attempt to create the new user
try {
crowdUser._id = await User.createWithPassword(crowdUser);
crowdUser._id = await User.create(crowdUser);

// sync the user data
await this.syncDataToUser(crowdUser, crowdUser._id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ export class ImportDataConverter {
async insertUser(userData: IImportUser): Promise<IUser> {
const password = `${Date.now()}${userData.name || ''}${userData.emails.length ? userData.emails[0].toUpperCase() : ''}`;
const userId = userData.emails.length
? await User.createWithPassword({
? await User.create({
email: userData.emails[0],
password,
})
: await User.createWithPassword({
: await User.create({
username: userData.username,
password,
joinDefaultChannelsSilenced: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ const saveNewUser = async function (userData, sendPassword) {
createUser.email = userData.email;
}

const _id = await User.createWithPassword(createUser);
const _id = await User.create(createUser);

const updateUser = {
$set: {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class SAML {
}
}

const userId = await User.create({ globalRoles: roles }, newUser);
const userId = await User.insertUserDoc({ globalRoles: roles }, newUser);
user = await Users.findOneById(userId);

if (user && userObject.channels && channelsAttributeUpdate !== true) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/slackbridge/server/RocketAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export default class RocketAdapter {
newUser.joinDefaultChannels = false;
}

rocketUserData.rocketId = await User.createWithPassword(newUser);
rocketUserData.rocketId = await User.create(newUser);
const userUpdate = {
utcOffset: rocketUserData.tz_offset / 3600, // Slack's is -18000 which translates to Rocket.Chat's after dividing by 3600,
roles: isBot ? ['bot'] : ['user'],
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/methods/registerUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Meteor.methods<ServerMethods>({
const AllowAnonymousWrite = settings.get<boolean>('Accounts_AllowAnonymousWrite');
const manuallyApproveNewUsers = settings.get<boolean>('Accounts_ManuallyApproveNewUsers');
if (AllowAnonymousRead === true && AllowAnonymousWrite === true && !formData.email) {
const userId = await User.create(
const userId = await User.insertUserDoc(
{
globalRoles: ['anonymous'],
},
Expand Down Expand Up @@ -104,7 +104,7 @@ Meteor.methods<ServerMethods>({
await Accounts.setPasswordAsync(importedUser._id, userData.password);
userId = importedUser._id;
} else {
userId = await User.createWithPassword(userData);
userId = await User.create(userData);
}
} catch (e) {
if (e instanceof Meteor.Error) {
Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/server/services/user/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export class UserService extends ServiceClassInternal implements IUserService {
}

private async validateNewUser(user: InsertionModel<IUser>): Promise<void> {
// validateNewUser
await this.validateRegistrationDisabled(user);
await this.validateDomainAllowList(user);
}
Expand Down Expand Up @@ -321,8 +320,6 @@ export class UserService extends ServiceClassInternal implements IUserService {
throw new Meteor.Error(400, 'Need to set a username or email');
}

// #TODO: Check if username and email are not already in use.

const user = {
...(username ? { username } : {}),
...(email ? { emails: [{ address: email, verified: false }] } : {}),
Expand Down
4 changes: 2 additions & 2 deletions packages/core-services/src/types/IUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export type CreateUserOptions = UserDocOptions & ({ username: string } | { email

export interface IUserService {
hashPassword(password: string | { algorithm: string; digest: string }): Promise<string>;
create(options: UserDocOptions, doc: Partial<InsertionModel<IUser>>): Promise<IUser['_id']>;
createWithPassword(options: CreateUserOptions): Promise<IUser['_id']>;
insertUserDoc(options: UserDocOptions, doc: Partial<InsertionModel<IUser>>): Promise<IUser['_id']>;
create(options: CreateUserOptions): Promise<IUser['_id']>;
}

0 comments on commit 10e15da

Please sign in to comment.