AddUserAndGroups Add a user and add it to multiple groups in a single transaction
(ctx *ctx.Context, coverTeams bool)
| 1078 | |
| 1079 | // AddUserAndGroups Add a user and add it to multiple groups in a single transaction |
| 1080 | func (u *User) AddUserAndGroups(ctx *ctx.Context, coverTeams bool) error { |
| 1081 | |
| 1082 | // Try to add a user |
| 1083 | if err := u.Add(ctx); err != nil { |
| 1084 | return errors.WithMessage(err, "failed to add user") |
| 1085 | } |
| 1086 | |
| 1087 | // Try to add a group for the user |
| 1088 | if err := UserGroupMemberSyncByUser(ctx, u, coverTeams); err != nil { |
| 1089 | return errors.WithMessage(err, "failed to add user to groups") |
| 1090 | } |
| 1091 | |
| 1092 | return nil |
| 1093 | } |
| 1094 | |
| 1095 | func (u *User) EncryptPhone() (err error) { |
| 1096 | // 从缓存获取手机号加密配置 |
no test coverage detected