mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 06:04:35 +08:00
email and password action/redusers work
This commit is contained in:
parent
eb0641d76a
commit
ea9a195f09
5 changed files with 60 additions and 7 deletions
|
@ -12,6 +12,24 @@ module ClientApi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def change_password
|
||||||
|
binding.pry
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_email
|
||||||
|
user = current_user
|
||||||
|
user.email = params['email']
|
||||||
|
saved_email = if user.save
|
||||||
|
user.email
|
||||||
|
else
|
||||||
|
user.reload.email
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: { email: saved_email } }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def change_full_name
|
def change_full_name
|
||||||
user = current_user
|
user = current_user
|
||||||
user.name = params['fullName']
|
user.name = params['fullName']
|
||||||
|
|
|
@ -25,6 +25,8 @@ export const RECENT_NOTIFICATIONS_PATH = "/client_api/recent_notifications";
|
||||||
export const CURRENT_USER_PATH = "/client_api/current_user_info";
|
export const CURRENT_USER_PATH = "/client_api/current_user_info";
|
||||||
export const CHANGE_USER_FULL_NAME_PATH = "/client_api/user/change_full_name";
|
export const CHANGE_USER_FULL_NAME_PATH = "/client_api/user/change_full_name";
|
||||||
export const CHANGE_USER_INITIALS_PATH = "/client_api/user/change_initials";
|
export const CHANGE_USER_INITIALS_PATH = "/client_api/user/change_initials";
|
||||||
|
export const CHANGE_USER_EMAIL_PATH = "/client_api/user/change_email";
|
||||||
|
export const CHANGE_USER_PASSWORD_PATH = "/client_api/user/change_password";
|
||||||
|
|
||||||
// info dropdown_title
|
// info dropdown_title
|
||||||
export const CUSTOMER_SUPPORT_LINK = "http://scinote.net/support";
|
export const CUSTOMER_SUPPORT_LINK = "http://scinote.net/support";
|
||||||
|
|
|
@ -3,7 +3,9 @@ import axios from "../../app/axios";
|
||||||
import {
|
import {
|
||||||
CHANGE_USER_FULL_NAME_PATH,
|
CHANGE_USER_FULL_NAME_PATH,
|
||||||
CURRENT_USER_PATH,
|
CURRENT_USER_PATH,
|
||||||
CHANGE_USER_INITIALS_PATH
|
CHANGE_USER_INITIALS_PATH,
|
||||||
|
CHANGE_USER_EMAIL_PATH,
|
||||||
|
CHANGE_USER_PASSWORD_PATH
|
||||||
} from "../../app/routes";
|
} from "../../app/routes";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -41,7 +43,7 @@ export function getCurrentUser() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function savedChangedFullName({ fullName }) {
|
export function saveFullName({ fullName }) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_CURRENT_USER_FULL_NAME,
|
type: CHANGE_CURRENT_USER_FULL_NAME,
|
||||||
payload: fullName
|
payload: fullName
|
||||||
|
@ -56,13 +58,13 @@ export function changeFullName(name) {
|
||||||
fullName: name
|
fullName: name
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
dispatch(savedChangedFullName(data));
|
dispatch(saveFullName(data));
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function savedChangeInitials({ initials }) {
|
export function saveInitials({ initials }) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_CURRENT_USER_INITIALS,
|
type: CHANGE_CURRENT_USER_INITIALS,
|
||||||
payload: initials
|
payload: initials
|
||||||
|
@ -77,26 +79,54 @@ export function changeInitials(initials) {
|
||||||
initials
|
initials
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
dispatch(savedChangeInitials(data));
|
dispatch(saveInitials(data));
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeEmail(email) {
|
export function saveEmail({ email }) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_CURRENT_USER_EMAIL,
|
type: CHANGE_CURRENT_USER_EMAIL,
|
||||||
payload: email
|
payload: email
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changePassword(password) {
|
export function changeEmail(email) {
|
||||||
|
return dispatch => {
|
||||||
|
axios
|
||||||
|
.post(CHANGE_USER_EMAIL_PATH, {
|
||||||
|
withCredentials: true,
|
||||||
|
email
|
||||||
|
})
|
||||||
|
.then(({ data }) => {
|
||||||
|
dispatch(saveEmail(data));
|
||||||
|
})
|
||||||
|
.catch(err => console.log(err));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function savePassword(password) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_CURRENT_USER_PASSWORD,
|
type: CHANGE_CURRENT_USER_PASSWORD,
|
||||||
payload: password
|
payload: password
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function changePassword(passwrd) {
|
||||||
|
return dispatch => {
|
||||||
|
axios
|
||||||
|
.post(CHANGE_USER_PASSWORD_PATH, {
|
||||||
|
withCredentials: true,
|
||||||
|
passwrd
|
||||||
|
})
|
||||||
|
.then(({ data }) => {
|
||||||
|
dispatch(savePassword(data));
|
||||||
|
})
|
||||||
|
.catch(err => console.log(err));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function changeAvatar(avatarSrc) {
|
export function changeAvatar(avatarSrc) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_CURRENT_USER_AVATAR,
|
type: CHANGE_CURRENT_USER_AVATAR,
|
||||||
|
|
|
@ -98,6 +98,7 @@ class InputEnabled extends Component {
|
||||||
<FormControl
|
<FormControl
|
||||||
type={this.props.inputType}
|
type={this.props.inputType}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
|
onChange={this.handleChange}
|
||||||
onKeyPress={this.handleKeyPress}
|
onKeyPress={this.handleKeyPress}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -27,6 +27,8 @@ Rails.application.routes.draw do
|
||||||
get '/current_user_info', to: 'users/users#current_user_info'
|
get '/current_user_info', to: 'users/users#current_user_info'
|
||||||
post '/user/change_full_name', to: 'users/users#change_full_name'
|
post '/user/change_full_name', to: 'users/users#change_full_name'
|
||||||
post '/user/change_initials', to: 'users/users#change_initials'
|
post '/user/change_initials', to: 'users/users#change_initials'
|
||||||
|
post '/user/change_email', to: 'users/users#change_email'
|
||||||
|
post '/user/change_password', to: 'users/users#change_password'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Save sample table state
|
# Save sample table state
|
||||||
|
|
Loading…
Add table
Reference in a new issue