mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
WIP - discourse/models/user not defined
This commit is contained in:
parent
f9894aec97
commit
38cc1962e7
@ -42,17 +42,15 @@ export default Controller.extend({
|
|||||||
if (isEmpty(this.newUsername)) return;
|
if (isEmpty(this.newUsername)) return;
|
||||||
if (this.unchanged) return;
|
if (this.unchanged) return;
|
||||||
|
|
||||||
User.checkUsername(
|
User.checkUsername(newUsername, undefined, this.get("model.id")).then(
|
||||||
newUsername,
|
result => {
|
||||||
undefined,
|
if (result.errors) {
|
||||||
this.get("model.id")
|
this.set("errorMessage", result.errors.join(" "));
|
||||||
).then(result => {
|
} else if (result.available === false) {
|
||||||
if (result.errors) {
|
this.set("taken", true);
|
||||||
this.set("errorMessage", result.errors.join(" "));
|
}
|
||||||
} else if (result.available === false) {
|
|
||||||
this.set("taken", true);
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -120,9 +120,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isInternal = DiscourseURL.isInternal(href);
|
const isInternal = DiscourseURL.isInternal(href);
|
||||||
const openExternalInNewTab = User.currentProp(
|
const openExternalInNewTab = User.currentProp("external_links_in_new_tab");
|
||||||
"external_links_in_new_tab"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!wantsNewWindow(e)) {
|
if (!wantsNewWindow(e)) {
|
||||||
if (!isInternal && openExternalInNewTab) {
|
if (!isInternal && openExternalInNewTab) {
|
||||||
|
@ -10,9 +10,7 @@ export function addFeaturedLinkMetaDecorator(decorator) {
|
|||||||
|
|
||||||
export function extractLinkMeta(topic) {
|
export function extractLinkMeta(topic) {
|
||||||
const href = topic.get("featured_link");
|
const href = topic.get("featured_link");
|
||||||
const target = User.currentProp("external_links_in_new_tab")
|
const target = User.currentProp("external_links_in_new_tab") ? "_blank" : "";
|
||||||
? "_blank"
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (!href) {
|
if (!href) {
|
||||||
return;
|
return;
|
||||||
|
@ -327,10 +327,7 @@ function staffExtensionsRegex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isAuthorizedFile(fileName) {
|
function isAuthorizedFile(fileName) {
|
||||||
if (
|
if (User.currentProp("staff") && staffExtensionsRegex().test(fileName)) {
|
||||||
User.currentProp("staff") &&
|
|
||||||
staffExtensionsRegex().test(fileName)
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return extensionsRegex().test(fileName);
|
return extensionsRegex().test(fileName);
|
||||||
|
@ -77,44 +77,43 @@ export default Mixin.create({
|
|||||||
|
|
||||||
checkUsernameAvailability: discourseDebounce(function() {
|
checkUsernameAvailability: discourseDebounce(function() {
|
||||||
if (this.shouldCheckUsernameAvailability()) {
|
if (this.shouldCheckUsernameAvailability()) {
|
||||||
return User.checkUsername(
|
return User.checkUsername(this.accountUsername, this.accountEmail).then(
|
||||||
this.accountUsername,
|
result => {
|
||||||
this.accountEmail
|
this.set("isDeveloper", false);
|
||||||
).then(result => {
|
if (result.available) {
|
||||||
this.set("isDeveloper", false);
|
if (result.is_developer) {
|
||||||
if (result.available) {
|
this.set("isDeveloper", true);
|
||||||
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 this.set(
|
return this.set(
|
||||||
"uniqueUsernameValidation",
|
"uniqueUsernameValidation",
|
||||||
EmberObject.create({
|
EmberObject.create({
|
||||||
failed: true,
|
ok: true,
|
||||||
reason: I18n.t("user.username.not_available", result)
|
reason: I18n.t("user.username.available")
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return this.set(
|
if (result.suggestion) {
|
||||||
"uniqueUsernameValidation",
|
return this.set(
|
||||||
EmberObject.create({
|
"uniqueUsernameValidation",
|
||||||
failed: true,
|
EmberObject.create({
|
||||||
reason: result.errors
|
failed: true,
|
||||||
? result.errors.join(" ")
|
reason: I18n.t("user.username.not_available", result)
|
||||||
: I18n.t("user.username.not_available_no_suggestion")
|
})
|
||||||
})
|
);
|
||||||
);
|
} else {
|
||||||
|
return this.set(
|
||||||
|
"uniqueUsernameValidation",
|
||||||
|
EmberObject.create({
|
||||||
|
failed: true,
|
||||||
|
reason: result.errors
|
||||||
|
? result.errors.join(" ")
|
||||||
|
: I18n.t("user.username.not_available_no_suggestion")
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}, 500),
|
}, 500),
|
||||||
|
|
||||||
|
@ -606,8 +606,7 @@ export default RestModel.extend({
|
|||||||
return this.findPostsByIds([postId])
|
return this.findPostsByIds([postId])
|
||||||
.then(posts => {
|
.then(posts => {
|
||||||
const ignoredUsers =
|
const ignoredUsers =
|
||||||
User.current() &&
|
User.current() && User.current().get("ignored_users");
|
||||||
User.current().get("ignored_users");
|
|
||||||
posts.forEach(p => {
|
posts.forEach(p => {
|
||||||
if (ignoredUsers && ignoredUsers.includes(p.username)) {
|
if (ignoredUsers && ignoredUsers.includes(p.username)) {
|
||||||
this.stream.removeObject(postId);
|
this.stream.removeObject(postId);
|
||||||
|
@ -27,7 +27,6 @@ import { Promise } from "rsvp";
|
|||||||
import { getProperties } from "@ember/object";
|
import { getProperties } from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import Site from "discourse/models/site";
|
import Site from "discourse/models/site";
|
||||||
import User from "discourse/models/user";
|
|
||||||
|
|
||||||
export const SECOND_FACTOR_METHODS = {
|
export const SECOND_FACTOR_METHODS = {
|
||||||
TOTP: 1,
|
TOTP: 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user