开通了 短信验证码登录。
按照云控制台如上图提示,写了注册和登录代码。
成功注册并登录后,在云控制台能够看到如下图的账号:
这里有个问题:我如何 给该账号 分配细腻级别的权限???
目前注册和登录功能都正常,但是找不到 入口 (没有相应的api)来 修改已注册账号的登录密码。
附注:
下面是react 前端代码:
import React, { Component } from "react";
import { connect } from "react-redux";
import PropTypes from "prop-types";
import { NavLink, Redirect} from "react-router-dom";
import { message } from 'antd';
import { signInAsync } from "../../redux/actions";
import {Auth} from "../../containers/app/app"
class Login extends Component {
state = {
phoneNumber: "",
pwd: "",
redirectToReferrer: false
};
static propTypes = {
isLogined: PropTypes.bool.isRequired,
signInAsync: PropTypes.func.isRequired,
};
handleLogin = (e) => {
e.preventDefault();
if (this.props.isLogined) {
this.setState({
phoneNumber: "",
pwd: "",
redirectToReferrer: true
});
return;
}
const phoneReg = /^1[3-9]\d{9}$/;
if (!phoneReg.test(this.state.phoneNumber)) {
message.warning("手机号格式不正确");
return;
}
const pwdReg =/^[\w_-]{6,16}$/;
//console.log(this.state.pwd)
if (!pwdReg.test()) {
message.warning("密码格式不正确");
return;
}
this.props.signInAsync(this.state.phoneNumber, this.state.pwd);
Auth.authenticate(() => {
});
this.setState({
phoneNumber: "",
pwd: "",
redirectToReferrer: true
});
};
handlePhoneChange = (event) => {
//console.log(event);
const phoneNumber = event.target.value;
this.setState({ phoneNumber });
};
handlePwdChange = (event) => {
const pwd = event.target.value;
this.setState({ pwd });
};
render() {
const { from } = this.props.location.state || { from: { pathname: "/input_data_table" } };
const { redirectToReferrer } = this.state;
if (redirectToReferrer) {
return <Redirect to={from} />;
}
return (
<div className="col-xs-6">
{this.props.isLogined && <div>您已登录</div>}
{! this.props.isLogined &&
<form>
<div className="form-group">
<label className="required">手机号码</label>
<input
type="text"
className="form-control"
id="phoneNumber"
placeholder="phoneNumber"
onChange={this.handlePhoneChange}
autoComplete="off"
/>
</div>
<div className="form-group">
<label className="required">密码</label>
<input
type="password"
className="form-control"
id="Password"
placeholder="Password"
onChange={this.handlePwdChange}
autoComplete="current-password"
/>
</div>
<ul className="nav nav-pills">
<li role="presentation">
<button
type="submit"
className="btn btn-default"
onClick={this.handleLogin}
>
登录
</button>
</li>
<li role="presentation">
<NavLink to="/register">注册</NavLink>
</li>
</ul>
</form>
}
</div>
);
}
}
export default connect((state) => ({ isLogined: state.isLogined }), {
signInAsync,
})(Login);
官方给出的参考文档:https://docs.cloudbase.net/api-reference/webv2/authentication
很有用。