WIP - discourse/models/user not defined

This commit is contained in:
Mark VanLandingham 2019-11-12 12:20:58 -06:00 committed by Robin Ward
parent f9894aec97
commit 38cc1962e7
7 changed files with 41 additions and 53 deletions

View File

@ -42,17 +42,15 @@ export default Controller.extend({
if (isEmpty(this.newUsername)) return;
if (this.unchanged) return;
User.checkUsername(
newUsername,
undefined,
this.get("model.id")
).then(result => {
if (result.errors) {
this.set("errorMessage", result.errors.join(" "));
} else if (result.available === false) {
this.set("taken", true);
User.checkUsername(newUsername, undefined, this.get("model.id")).then(
result => {
if (result.errors) {
this.set("errorMessage", result.errors.join(" "));
} else if (result.available === false) {
this.set("taken", true);
}
}
});
);
}
},

View File

@ -120,9 +120,7 @@ export default {
}
const isInternal = DiscourseURL.isInternal(href);
const openExternalInNewTab = User.currentProp(
"external_links_in_new_tab"
);
const openExternalInNewTab = User.currentProp("external_links_in_new_tab");
if (!wantsNewWindow(e)) {
if (!isInternal && openExternalInNewTab) {

View File

@ -10,9 +10,7 @@ export function addFeaturedLinkMetaDecorator(decorator) {
export function extractLinkMeta(topic) {
const href = topic.get("featured_link");
const target = User.currentProp("external_links_in_new_tab")
? "_blank"
: "";
const target = User.currentProp("external_links_in_new_tab") ? "_blank" : "";
if (!href) {
return;

View File

@ -327,10 +327,7 @@ function staffExtensionsRegex() {
}
function isAuthorizedFile(fileName) {
if (
User.currentProp("staff") &&
staffExtensionsRegex().test(fileName)
) {
if (User.currentProp("staff") && staffExtensionsRegex().test(fileName)) {
return true;
}
return extensionsRegex().test(fileName);

View File

@ -77,44 +77,43 @@ export default Mixin.create({
checkUsernameAvailability: discourseDebounce(function() {
if (this.shouldCheckUsernameAvailability()) {
return User.checkUsername(
this.accountUsername,
this.accountEmail
).then(result => {
this.set("isDeveloper", false);
if (result.available) {
if (result.is_developer) {
this.set("isDeveloper", true);
}
return this.set(
"uniqueUsernameValidation",
EmberObject.create({
ok: true,
reason: I18n.t("user.username.available")
})
);
} else {
if (result.suggestion) {
return User.checkUsername(this.accountUsername, this.accountEmail).then(
result => {
this.set("isDeveloper", false);
if (result.available) {
if (result.is_developer) {
this.set("isDeveloper", true);
}
return this.set(
"uniqueUsernameValidation",
EmberObject.create({
failed: true,
reason: I18n.t("user.username.not_available", result)
ok: true,
reason: I18n.t("user.username.available")
})
);
} else {
return this.set(
"uniqueUsernameValidation",
EmberObject.create({
failed: true,
reason: result.errors
? result.errors.join(" ")
: I18n.t("user.username.not_available_no_suggestion")
})
);
if (result.suggestion) {
return this.set(
"uniqueUsernameValidation",
EmberObject.create({
failed: true,
reason: I18n.t("user.username.not_available", result)
})
);
} else {
return this.set(
"uniqueUsernameValidation",
EmberObject.create({
failed: true,
reason: result.errors
? result.errors.join(" ")
: I18n.t("user.username.not_available_no_suggestion")
})
);
}
}
}
});
);
}
}, 500),

View File

@ -606,8 +606,7 @@ export default RestModel.extend({
return this.findPostsByIds([postId])
.then(posts => {
const ignoredUsers =
User.current() &&
User.current().get("ignored_users");
User.current() && User.current().get("ignored_users");
posts.forEach(p => {
if (ignoredUsers && ignoredUsers.includes(p.username)) {
this.stream.removeObject(postId);

View File

@ -27,7 +27,6 @@ import { Promise } from "rsvp";
import { getProperties } from "@ember/object";
import deprecated from "discourse-common/lib/deprecated";
import Site from "discourse/models/site";
import User from "discourse/models/user";
export const SECOND_FACTOR_METHODS = {
TOTP: 1,