Browse Source

fix: user command stuff

develop
Alex Mikhalev 6 years ago
parent
commit
1dd446c6fc
  1. 5
      server/commands/user.ts
  2. 7
      server/entities/User.ts
  3. 3
      server/repositories/UserRepository.ts

5
server/commands/user.ts

@ -14,6 +14,8 @@ type UserFlags = (typeof UserCommand)["flags"] extends Input<infer F> @@ -14,6 +14,8 @@ type UserFlags = (typeof UserCommand)["flags"] extends Input<infer F>
type Action = "create" | "update" | "delete";
// tslint:disable:no-shadowed-variable
export default class UserCommand extends ManageCommand {
static description = "Manage users";
@ -105,7 +107,7 @@ export default class UserCommand extends ManageCommand { @@ -105,7 +107,7 @@ export default class UserCommand extends ManageCommand {
const user = await this.getOrDeleteUser(flags, action);
if (flags.id != null && flags.username) {
if (flags.username && (flags.create || flags.id)) {
user.username = flags.username;
}
if (flags.name) {
@ -122,7 +124,6 @@ export default class UserCommand extends ManageCommand { @@ -122,7 +124,6 @@ export default class UserCommand extends ManageCommand {
await this.database.users.save(user);
this.log(`${capitalize(action)}d user id ${user.id} (${user.username})`);
} catch (e) {
console.log(e)
throw e;
}
}

7
server/entities/User.ts

@ -3,13 +3,10 @@ import { omit } from "lodash"; @@ -3,13 +3,10 @@ import { omit } from "lodash";
import {
Column,
Entity,
Index,
JoinTable,
ManyToMany,
PrimaryGeneratedColumn,
BeforeInsert,
BeforeUpdate,
Index,
InsertEvent
PrimaryGeneratedColumn
} from "typeorm";
import { IUser } from "@common/httpApi";

3
server/repositories/UserRepository.ts

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
import { EntityRepository, FindOneOptions, Repository, DeepPartial, FindConditions, SaveOptions } from "typeorm";
import { EntityRepository, FindConditions, FindOneOptions, Repository } from "typeorm";
import ApiError from "@common/ApiError";
import { User } from "@server/entities";
export interface FindUserOptions extends FindOneOptions<User> {

Loading…
Cancel
Save