Skip to content

Commit f6e4fa7

Browse files
author
Daan Hoogland
committed
read user.uuid from DB
1 parent 34f6f41 commit f6e4fa7

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

api/src/main/java/com/cloud/user/User.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public enum Source {
3535

3636
public String getUuid();
3737

38+
public void setUuid(String uuid);
39+
3840
public Date getCreated();
3941

4042
public Date getRemoved();

engine/schema/src/main/java/com/cloud/user/UserVO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public UserVO() {
123123
}
124124

125125
public UserVO(long id) {
126+
this();
126127
this.id = id;
127-
this.uuid = UUID.randomUUID().toString();
128128
}
129129

130130
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, Source source) {

engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
@Component
4444
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
45-
private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, u.api_key_access, "
45+
private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.uuid u.username, u.account_id, u.secret_key, u.state, u.api_key_access, "
4646
+ "a.id, a.account_name, a.type, a.role_id, a.domain_id, a.state, a.api_key_access " + "FROM `cloud`.`user` u, `cloud`.`account` a "
4747
+ "WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
4848

@@ -145,24 +145,25 @@ public Pair<User, Account> findUserAccountByApiKey(String apiKey) {
145145
// TODO: make sure we don't have more than 1 result? ApiKey had better be unique
146146
if (rs.next()) {
147147
User u = new UserVO(rs.getLong(1));
148-
u.setUsername(rs.getString(2));
149-
u.setAccountId(rs.getLong(3));
150-
u.setSecretKey(DBEncryptionUtil.decrypt(rs.getString(4)));
151-
u.setState(State.getValueOf(rs.getString(5)));
152-
boolean apiKeyAccess = rs.getBoolean(6);
148+
u.setUuid(rs.getString(2));
149+
u.setUsername(rs.getString(3));
150+
u.setAccountId(rs.getLong(4));
151+
u.setSecretKey(DBEncryptionUtil.decrypt(rs.getString(5)));
152+
u.setState(State.getValueOf(rs.getString(6)));
153+
boolean apiKeyAccess = rs.getBoolean(7);
153154
if (rs.wasNull()) {
154155
u.setApiKeyAccess(null);
155156
} else {
156157
u.setApiKeyAccess(apiKeyAccess);
157158
}
158159

159-
AccountVO a = new AccountVO(rs.getLong(7));
160-
a.setAccountName(rs.getString(8));
161-
a.setType(Account.Type.getFromValue(rs.getInt(9)));
162-
a.setRoleId(rs.getLong(10));
163-
a.setDomainId(rs.getLong(11));
164-
a.setState(State.getValueOf(rs.getString(12)));
165-
apiKeyAccess = rs.getBoolean(13);
160+
AccountVO a = new AccountVO(rs.getLong(8));
161+
a.setAccountName(rs.getString(9));
162+
a.setType(Account.Type.getFromValue(rs.getInt(10)));
163+
a.setRoleId(rs.getLong(11));
164+
a.setDomainId(rs.getLong(12));
165+
a.setState(State.getValueOf(rs.getString(13)));
166+
apiKeyAccess = rs.getBoolean(14);
166167
if (rs.wasNull()) {
167168
a.setApiKeyAccess(null);
168169
} else {

0 commit comments

Comments
 (0)