mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
improve logging
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
package sonia.scm.security;
|
package sonia.scm.security;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.shiro.authc.AuthenticationInfo;
|
import org.apache.shiro.authc.AuthenticationInfo;
|
||||||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
||||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||||
@@ -48,6 +49,7 @@ import java.util.Set;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Extension
|
@Extension
|
||||||
public final class SyncingRealmHelper {
|
public final class SyncingRealmHelper {
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@ public final class SyncingRealmHelper {
|
|||||||
if (userManager.contains(user.getName())) {
|
if (userManager.contains(user.getName())) {
|
||||||
User clone = user.clone();
|
User clone = user.clone();
|
||||||
if (!externalUserConverters.isEmpty()) {
|
if (!externalUserConverters.isEmpty()) {
|
||||||
|
log.debug("execute available user converters");
|
||||||
for (ExternalUserConverter converter : externalUserConverters) {
|
for (ExternalUserConverter converter : externalUserConverters) {
|
||||||
clone = converter.convert(clone);
|
clone = converter.convert(clone);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@
|
|||||||
*/
|
*/
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { WithTranslation, withTranslation } from "react-i18next";
|
import { WithTranslation, withTranslation } from "react-i18next";
|
||||||
import { User, Link } from "@scm-manager/ui-types";
|
import { Link, User } from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
ErrorNotification,
|
||||||
InputField,
|
InputField,
|
||||||
Level,
|
Level,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -50,6 +51,7 @@ type State = {
|
|||||||
displayNameValidationError: boolean;
|
displayNameValidationError: boolean;
|
||||||
passwordValid: boolean;
|
passwordValid: boolean;
|
||||||
showPasswordModal: boolean;
|
showPasswordModal: boolean;
|
||||||
|
error?: Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserForm extends React.Component<Props, State> {
|
class UserForm extends React.Component<Props, State> {
|
||||||
@@ -126,19 +128,34 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
const { user, passwordValid } = this.state;
|
const { user, passwordValid } = this.state;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!this.isInvalid()) {
|
if (!this.isInvalid()) {
|
||||||
this.props.submitForm(this.state.user);
|
|
||||||
if (user.password && passwordValid) {
|
if (user.password && passwordValid) {
|
||||||
setPassword((user._links.password as Link).href, user.password);
|
setPassword((user._links.password as Link).href, user.password).catch();
|
||||||
//TODO handle error
|
|
||||||
}
|
}
|
||||||
|
this.props.submitForm(this.state.user);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, t } = this.props;
|
const { loading, t } = this.props;
|
||||||
const { user, showPasswordModal, passwordValid } = this.state;
|
const { user, showPasswordModal, passwordValid, error } = this.state;
|
||||||
|
|
||||||
const passwordChangeField = <PasswordConfirmation passwordChanged={this.handlePasswordChange} />;
|
const passwordChangeField = <PasswordConfirmation passwordChanged={this.handlePasswordChange} />;
|
||||||
|
const passwordModal = (
|
||||||
|
<Modal
|
||||||
|
body={passwordChangeField}
|
||||||
|
closeFunction={() => this.setState({ user: { ...user, external: true } }, () => this.showPasswordModal(false))}
|
||||||
|
active={showPasswordModal}
|
||||||
|
title={t("userForm.modal.passwordRequired")}
|
||||||
|
footer={
|
||||||
|
<SubmitButton
|
||||||
|
action={() => !!user.password && passwordValid && this.showPasswordModal(false)}
|
||||||
|
disabled={!this.state.passwordValid}
|
||||||
|
scrollToTop={false}
|
||||||
|
label={t("userForm.modal.setPassword")}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
let nameField = null;
|
let nameField = null;
|
||||||
let subtitle = null;
|
let subtitle = null;
|
||||||
if (!this.props.user) {
|
if (!this.props.user) {
|
||||||
@@ -160,30 +177,14 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
subtitle = <Subtitle subtitle={t("userForm.subtitle")} />;
|
subtitle = <Subtitle subtitle={t("userForm.subtitle")} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showPasswordModal) {
|
if (error) {
|
||||||
return (
|
return <ErrorNotification error={error} />;
|
||||||
<Modal
|
|
||||||
body={passwordChangeField}
|
|
||||||
closeFunction={() =>
|
|
||||||
this.setState({ user: { ...user, external: true } }, () => this.showPasswordModal(false))
|
|
||||||
}
|
|
||||||
active={showPasswordModal}
|
|
||||||
title={"userForm.modal.passwordRequired"}
|
|
||||||
footer={
|
|
||||||
<SubmitButton
|
|
||||||
action={() => !!user.password && passwordValid && this.showPasswordModal(false)}
|
|
||||||
disabled={!this.state.passwordValid}
|
|
||||||
scrollToTop={false}
|
|
||||||
label={t("userForm.modal.setPassword")}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{subtitle}
|
{subtitle}
|
||||||
|
{showPasswordModal && passwordModal}
|
||||||
<form onSubmit={this.submit}>
|
<form onSubmit={this.submit}>
|
||||||
<div className="columns is-multiline">
|
<div className="columns is-multiline">
|
||||||
{nameField}
|
{nameField}
|
||||||
@@ -298,8 +299,8 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
external
|
external
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//Only show password modal if edit mode and external flag was changed to internal
|
//Only show password modal if edit mode and external flag was changed to internal and password was not already set
|
||||||
() => !external && this.props.user?.external && this.showPasswordModal(true)
|
() => !external && this.props.user?.external && !this.state.user.password && this.showPasswordModal(true)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,13 @@
|
|||||||
|
|
||||||
package sonia.scm.user;
|
package sonia.scm.user;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.plugin.Extension;
|
import sonia.scm.plugin.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Extension
|
@Extension
|
||||||
public class InternalToExternalUserConverter implements ExternalUserConverter{
|
public class InternalToExternalUserConverter implements ExternalUserConverter{
|
||||||
|
|
||||||
@@ -40,15 +42,15 @@ public class InternalToExternalUserConverter implements ExternalUserConverter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public User convert(User user) {
|
public User convert(User user) {
|
||||||
if (shouldNotConvertUser(user)) {
|
if (shouldConvertUser(user)) {
|
||||||
return user;
|
log.info("Convert internal user {} to external", user.getId());
|
||||||
}
|
|
||||||
user.setExternal(true);
|
user.setExternal(true);
|
||||||
user.setPassword(null);
|
user.setPassword(null);
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldNotConvertUser(User user) {
|
private boolean shouldConvertUser(User user) {
|
||||||
return user.isExternal() || !scmConfiguration.isEnabledUserConverter();
|
return !user.isExternal() && scmConfiguration.isEnabledUserConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user